Skip to content

Commit ec238bf

Browse files
committed
Address feedback
1 parent 92d65d8 commit ec238bf

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/lib/list/selection-list.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ describe('MatSelectionList with forms', () => {
496496
.map(optionDebugEl => optionDebugEl.componentInstance);
497497
});
498498

499-
it('should update the model if an option got selected', fakeAsync(() => {
499+
it('should update the model if an option got selected programmatically', fakeAsync(() => {
500500
expect(fixture.componentInstance.selectedOptions.length)
501501
.toBe(0, 'Expected no options to be selected by default');
502502

@@ -608,8 +608,8 @@ describe('MatSelectionList with forms', () => {
608608
fixture.componentInstance.formControl.setValue(['opt2', 'opt3']);
609609
fixture.detectChanges();
610610

611-
expect(listOptions[1].selected).toBe(true, 'Expected option to be selected.');
612-
expect(listOptions[2].selected).toBe(true, 'Expected option to be selected.');
611+
expect(listOptions[1].selected).toBe(true, 'Expected first option to be selected.');
612+
expect(listOptions[2].selected).toBe(true, 'Expected second option to be selected.');
613613

614614
fixture.componentInstance.formControl.setValue(null);
615615
fixture.detectChanges();

src/lib/list/selection-list.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,17 +351,17 @@ export class MatSelectionList extends _MatSelectionListMixinBase implements Focu
351351
}
352352

353353
/** Implemented as part of ControlValueAccessor. */
354-
registerOnChange(fn: any): void {
354+
registerOnChange(fn: (value: any) => void): void {
355355
this._onChange = fn;
356356
}
357357

358358
/** Implemented as part of ControlValueAccessor. */
359-
registerOnTouched(fn: any): void {
359+
registerOnTouched(fn: () => void): void {
360360
this.onTouched = fn;
361361
}
362362

363363
/** Returns the option with the specified value. */
364-
private _getOptionFromValue(value: string): MatListOption | undefined {
364+
private _getOptionByValue(value: string): MatListOption | undefined {
365365
return this.options.find(option => option.value === value);
366366
}
367367

@@ -370,8 +370,8 @@ export class MatSelectionList extends _MatSelectionListMixinBase implements Focu
370370
this.options.forEach(option => option._setSelected(false));
371371

372372
values
373-
.map(value => this._getOptionFromValue(value))
374-
.filter(option => !!option)
373+
.map(value => this._getOptionByValue(value))
374+
.filter(Boolean)
375375
.forEach(option => option!._setSelected(true));
376376
}
377377

0 commit comments

Comments
 (0)