Skip to content

Commit 5248d55

Browse files
committed
chore: hide internal properties from selection-list api doc
* Recently with the NgModel support for the selection list, the `onTouched` property has been added. This one needs to be prefixed with an underscore to be hidden in the docs. * Since the initial implementation of the selection-list the `selectionList` variable has been initialized publically in the constructor of the `MatListOption` and therefore shows up in the docs. This property has been made private now.
1 parent d7d995d commit 5248d55

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

src/lib/list/selection-list.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ export class MatListOption extends _MatListOptionMixinBase
126126

127127
/** Whether the option is disabled. */
128128
@Input()
129-
get disabled() { return (this.selectionList && this.selectionList.disabled) || this._disabled; }
129+
get disabled() {
130+
return this._disabled || this._selectionList && this._selectionList.disabled;
131+
}
130132
set disabled(value: any) {
131133
const newValue = coerceBooleanProperty(value);
132134

@@ -138,13 +140,13 @@ export class MatListOption extends _MatListOptionMixinBase
138140

139141
/** Whether the option is selected. */
140142
@Input()
141-
get selected(): boolean { return this.selectionList.selectedOptions.isSelected(this); }
143+
get selected(): boolean { return this._selectionList.selectedOptions.isSelected(this); }
142144
set selected(value: boolean) {
143145
const isSelected = coerceBooleanProperty(value);
144146

145147
if (isSelected !== this._selected) {
146148
this._setSelected(isSelected);
147-
this.selectionList._reportValueChange();
149+
this._selectionList._reportValueChange();
148150
}
149151
}
150152

@@ -158,7 +160,7 @@ export class MatListOption extends _MatListOptionMixinBase
158160
constructor(private _element: ElementRef,
159161
private _changeDetector: ChangeDetectorRef,
160162
@Optional() @Inject(forwardRef(() => MatSelectionList))
161-
public selectionList: MatSelectionList) {
163+
private _selectionList: MatSelectionList) {
162164
super();
163165
}
164166

@@ -169,7 +171,7 @@ export class MatListOption extends _MatListOptionMixinBase
169171
// available options. Also it can happen that the ControlValueAccessor has an initial value
170172
// that should be used instead. Deferring the value change report to the next tick ensures
171173
// that the form control value is not being overwritten.
172-
Promise.resolve(() => this.selected && this.selectionList._reportValueChange());
174+
Promise.resolve(() => this.selected && this._selectionList._reportValueChange());
173175
}
174176
}
175177

@@ -178,7 +180,7 @@ export class MatListOption extends _MatListOptionMixinBase
178180
}
179181

180182
ngOnDestroy(): void {
181-
this.selectionList._removeOptionFromList(this);
183+
this._selectionList._removeOptionFromList(this);
182184
}
183185

184186
/** Toggles the selection state of the option. */
@@ -193,15 +195,15 @@ export class MatListOption extends _MatListOptionMixinBase
193195

194196
/** Whether this list item should show a ripple effect when clicked. */
195197
_isRippleDisabled() {
196-
return this.disabled || this.disableRipple || this.selectionList.disableRipple;
198+
return this.disabled || this.disableRipple || this._selectionList.disableRipple;
197199
}
198200

199201
_handleClick() {
200202
if (!this.disabled) {
201203
this.toggle();
202204

203205
// Emit a change event if the selected state of the option changed through user interaction.
204-
this.selectionList._emitChangeEvent(this);
206+
this._selectionList._emitChangeEvent(this);
205207

206208
// TODO: the `selectionChange` event on the option is deprecated. Remove that in the future.
207209
this._emitDeprecatedChangeEvent();
@@ -210,12 +212,12 @@ export class MatListOption extends _MatListOptionMixinBase
210212

211213
_handleFocus() {
212214
this._hasFocus = true;
213-
this.selectionList._setFocusedOption(this);
215+
this._selectionList._setFocusedOption(this);
214216
}
215217

216218
_handleBlur() {
217219
this._hasFocus = false;
218-
this.selectionList.onTouched();
220+
this._selectionList._onTouched();
219221
}
220222

221223
/** Retrieves the DOM element of the component host. */
@@ -232,9 +234,9 @@ export class MatListOption extends _MatListOptionMixinBase
232234
this._selected = selected;
233235

234236
if (selected) {
235-
this.selectionList.selectedOptions.select(this);
237+
this._selectionList.selectedOptions.select(this);
236238
} else {
237-
this.selectionList.selectedOptions.deselect(this);
239+
this._selectionList.selectedOptions.deselect(this);
238240
}
239241

240242
this._changeDetector.markForCheck();
@@ -261,7 +263,7 @@ export class MatListOption extends _MatListOptionMixinBase
261263
'[tabIndex]': 'tabIndex',
262264
'class': 'mat-selection-list',
263265
'(focus)': 'focus()',
264-
'(blur)': 'onTouched()',
266+
'(blur)': '_onTouched()',
265267
'(keydown)': '_keydown($event)',
266268
'[attr.aria-disabled]': 'disabled.toString()'},
267269
template: '<ng-content></ng-content>',
@@ -291,7 +293,7 @@ export class MatSelectionList extends _MatSelectionListMixinBase implements Focu
291293
private _onChange: (value: any) => void = (_: any) => {};
292294

293295
/** View to model callback that should be called if the list or its options lost focus. */
294-
onTouched: () => void = () => {};
296+
_onTouched: () => void = () => {};
295297

296298
constructor(private _element: ElementRef, @Attribute('tabindex') tabIndex: string) {
297299
super();
@@ -385,7 +387,7 @@ export class MatSelectionList extends _MatSelectionListMixinBase implements Focu
385387

386388
/** Implemented as part of ControlValueAccessor. */
387389
registerOnTouched(fn: () => void): void {
388-
this.onTouched = fn;
390+
this._onTouched = fn;
389391
}
390392

391393
/** Returns the option with the specified value. */

0 commit comments

Comments
 (0)