Skip to content

Commit ed1569c

Browse files
committed
refactor(slider): Change access modifiers for fields to public
Changes access modifies to _ngZone, _foundation, _elmentRef, and _componentRef so that we won't neeed getter methods.
1 parent 8a1b5b3 commit ed1569c

File tree

1 file changed

+20
-36
lines changed
  • src/material-experimental/mdc-slider

1 file changed

+20
-36
lines changed

src/material-experimental/mdc-slider/slider.ts

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -74,33 +74,33 @@ class SliderAdapter implements MDCSliderAdapter {
7474
constructor(private _delegate: MatSlider) {}
7575

7676
hasClass = (className: string) =>
77-
this._delegate.getElementRef().nativeElement.classList.contains(className);
77+
this._delegate._elementRef.nativeElement.classList.contains(className);
7878
addClass = (className: string) =>
79-
this._delegate.getElementRef().nativeElement.classList.add(className);
79+
this._delegate._elementRef.nativeElement.classList.add(className);
8080
removeClass = (className: string) =>
81-
this._delegate.getElementRef().nativeElement.classList.remove(className);
82-
getAttribute = (name: string) => this._delegate.getElementRef().nativeElement.getAttribute(name);
81+
this._delegate._elementRef.nativeElement.classList.remove(className);
82+
getAttribute = (name: string) => this._delegate._elementRef.nativeElement.getAttribute(name);
8383
setAttribute = (name: string, value: string) =>
84-
this._delegate.getElementRef().nativeElement.setAttribute(name, value);
84+
this._delegate._elementRef.nativeElement.setAttribute(name, value);
8585
removeAttribute = (name: string) =>
86-
this._delegate.getElementRef().nativeElement.removeAttribute(name);
87-
computeBoundingRect = () => this._delegate.getElementRef().nativeElement.getBoundingClientRect();
88-
getTabIndex = () => this._delegate.getElementRef().nativeElement.tabIndex;
86+
this._delegate._elementRef.nativeElement.removeAttribute(name);
87+
computeBoundingRect = () => this._delegate._elementRef.nativeElement.getBoundingClientRect();
88+
getTabIndex = () => this._delegate._elementRef.nativeElement.tabIndex;
8989
registerInteractionHandler = (evtType: any, handler: (this: HTMLElement, ev: any) => any) =>
9090
// Interaction event handlers (which handle keyboard interaction) cannot be passive
9191
// as they will prevent the default behavior. Additionally we can't run these event
9292
// handlers outside of the Angular zone because we rely on the events to cause the
9393
// component tree to be re-checked.
9494
// TODO: take in the event listener options from the adapter once MDC supports it.
95-
this._delegate.getElementRef().nativeElement.addEventListener(
95+
this._delegate._elementRef.nativeElement.addEventListener(
9696
evtType, handler, activeListenerOptions)
9797
deregisterInteractionHandler = (evtType: any, handler: (this: HTMLElement, ev: any) => any) =>
98-
this._delegate.getElementRef().nativeElement.removeEventListener(evtType, handler)
98+
this._delegate._elementRef.nativeElement.removeEventListener(evtType, handler)
9999
registerThumbContainerInteractionHandler =
100100
(evtType: any, handler: (this: HTMLElement, ev: any) => any) => {
101101
// The thumb container interaction handlers are currently just used for transition
102102
// events which don't need to run in the Angular zone.
103-
this._delegate.getNgZone().runOutsideAngular(() => {
103+
this._delegate._ngZone.runOutsideAngular(() => {
104104
this._delegate._thumbContainer.nativeElement
105105
.addEventListener(evtType, handler, passiveListenerOptions);
106106
});
@@ -121,13 +121,13 @@ class SliderAdapter implements MDCSliderAdapter {
121121
registerResizeHandler = (handler: (this: Window, ev: UIEvent) => any) => {
122122
// The resize handler is currently responsible for detecting slider dimension
123123
// changes and therefore doesn't cause a value change that needs to be propagated.
124-
this._delegate.getNgZone().runOutsideAngular(() => window.addEventListener('resize', handler));
124+
this._delegate._ngZone.runOutsideAngular(() => window.addEventListener('resize', handler));
125125
}
126126
deregisterResizeHandler =
127127
(handler: (this: Window, ev: UIEvent) => any) => window.removeEventListener('resize', handler)
128128
notifyInput =
129129
() => {
130-
const newValue = this._delegate.getFoundation().getValue();
130+
const newValue = this._delegate._foundation.getValue();
131131
// MDC currently fires the input event multiple times.
132132
// TODO(devversion): remove this check once the input notifications are fixed.
133133
if (newValue !== this._delegate.value) {
@@ -141,7 +141,7 @@ class SliderAdapter implements MDCSliderAdapter {
141141
// updated the value. Material and native range sliders also emit an input event.
142142
// Usually we sync the "value" in the "input" event, but as a workaround we now sync
143143
// the value in the "change" event.
144-
this._delegate.value = this._delegate.getFoundation().getValue();
144+
this._delegate.value = this._delegate._foundation.getValue();
145145
this._delegate._emitChangeEvent(this._delegate.value!);
146146
};
147147
setThumbContainerStyleProperty =
@@ -155,7 +155,7 @@ class SliderAdapter implements MDCSliderAdapter {
155155
setMarkerValue =
156156
() => {
157157
// Mark the component for check as the thumb label needs to be re-rendered.
158-
this._delegate.getChangeDetectorRef().markForCheck();
158+
this._delegate._changeDetectorRef.markForCheck();
159159
}
160160
setTrackMarkers =
161161
(step: number, max: number, min: number) => {
@@ -319,7 +319,7 @@ export class MatSlider implements AfterViewInit, OnChanges, OnDestroy, ControlVa
319319
private _sliderAdapter: MDCSliderAdapter = new SliderAdapter(this);
320320

321321
/** Instance of the MDC slider foundation for this slider. */
322-
private _foundation = new MDCSliderFoundation(this._sliderAdapter);
322+
_foundation = new MDCSliderFoundation(this._sliderAdapter);
323323

324324
/** Whether the MDC foundation has been initialized. */
325325
private _isInitialized = false;
@@ -339,10 +339,10 @@ export class MatSlider implements AfterViewInit, OnChanges, OnDestroy, ControlVa
339339
@ViewChild('trackMarker') _trackMarker: ElementRef<HTMLElement>;
340340

341341
constructor(
342-
private _elementRef: ElementRef<HTMLElement>,
343-
private _changeDetectorRef: ChangeDetectorRef,
344-
private _ngZone: NgZone,
345-
private _platform: Platform,
342+
public _elementRef: ElementRef<HTMLElement>,
343+
public _changeDetectorRef: ChangeDetectorRef,
344+
public _ngZone: NgZone,
345+
public _platform: Platform,
346346
@Optional() private _dir: Directionality,
347347
@Attribute('tabindex') tabIndex: string,
348348
@Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode?: string) {
@@ -424,22 +424,6 @@ export class MatSlider implements AfterViewInit, OnChanges, OnDestroy, ControlVa
424424
}
425425
}
426426

427-
getChangeDetectorRef() {
428-
return this._changeDetectorRef;
429-
}
430-
431-
getElementRef() {
432-
return this._elementRef;
433-
}
434-
435-
getFoundation() {
436-
return this._foundation;
437-
}
438-
439-
getNgZone() {
440-
return this._ngZone;
441-
}
442-
443427
/** Focuses the slider. */
444428
focus(options?: FocusOptions) {
445429
this._elementRef.nativeElement.focus(options);

0 commit comments

Comments
 (0)