Skip to content

Commit 6573f09

Browse files
committed
Address feedback
1 parent 1a91c48 commit 6573f09

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
@@ -539,7 +539,7 @@ describe('MatSelectionList with forms', () => {
539539
.map(optionDebugEl => optionDebugEl.componentInstance);
540540
});
541541

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

@@ -651,8 +651,8 @@ describe('MatSelectionList with forms', () => {
651651
fixture.componentInstance.formControl.setValue(['opt2', 'opt3']);
652652
fixture.detectChanges();
653653

654-
expect(listOptions[1].selected).toBe(true, 'Expected option to be selected.');
655-
expect(listOptions[2].selected).toBe(true, 'Expected option to be selected.');
654+
expect(listOptions[1].selected).toBe(true, 'Expected first option to be selected.');
655+
expect(listOptions[2].selected).toBe(true, 'Expected second option to be selected.');
656656

657657
fixture.componentInstance.formControl.setValue(null);
658658
fixture.detectChanges();

src/lib/list/selection-list.ts

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

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

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

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

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

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

0 commit comments

Comments
 (0)