Skip to content

Commit fa89805

Browse files
committed
fixup! fix(material/list): Do not rely on input binding order
1 parent 941055c commit fa89805

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ describe('MatSelectionList without forms', () => {
3939
SelectionListWithListDisabled,
4040
SelectionListWithOnlyOneOption,
4141
SelectionListWithIndirectChildOptions,
42+
SelectionListWithSelectedOptionAndValue,
4243
],
4344
});
4445

@@ -594,6 +595,14 @@ describe('MatSelectionList without forms', () => {
594595
.toBe(0, 'Expected no ripples after list ripples are disabled.');
595596
}));
596597

598+
it('can bind both selected and value at the same time', () => {
599+
const fixture = TestBed.createComponent(SelectionListWithSelectedOptionAndValue);
600+
fixture.detectChanges();
601+
const listItemEl = fixture.debugElement.query(By.directive(MatListOption))!;
602+
expect(listItemEl.componentInstance.selected).toBe(true);
603+
expect(listItemEl.componentInstance.value).toBe(fixture.componentInstance.itemValue);
604+
});
605+
597606
});
598607

599608
describe('with list option selected', () => {
@@ -1191,18 +1200,6 @@ describe('MatSelectionList with forms', () => {
11911200
expect(testComponent.optionInstances.toArray()[1].selected).toBe(true);
11921201
}));
11931202
});
1194-
1195-
it('can bind both selected and value at the same time', () => {
1196-
const fixture =
1197-
TestBed
1198-
.configureTestingModule(
1199-
{imports: [MatListModule], declarations: [SelectionListWithSelectedOptionAndValue]})
1200-
.createComponent(SelectionListWithSelectedOptionAndValue);
1201-
fixture.detectChanges();
1202-
const listItemEl = fixture.debugElement.query(By.directive(MatListOption))!;
1203-
expect(listItemEl.componentInstance.selected).toBe(true);
1204-
expect(listItemEl.componentInstance.value).toBe(fixture.componentInstance.itemValue);
1205-
});
12061203
});
12071204

12081205

src/material/list/selection-list.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,8 @@ export class MatSelectionListChange {
116116
encapsulation: ViewEncapsulation.None,
117117
changeDetection: ChangeDetectionStrategy.OnPush,
118118
})
119-
export class MatListOption extends _MatListOptionMixinBase implements AfterContentInit, OnChanges,
120-
OnDestroy, OnInit,
121-
FocusableOption,
119+
export class MatListOption extends _MatListOptionMixinBase implements AfterContentInit, OnDestroy,
120+
OnInit, FocusableOption,
122121
CanDisableRipple {
123122
private _selected = false;
124123
private _disabled = false;
@@ -208,9 +207,6 @@ export class MatListOption extends _MatListOptionMixinBase implements AfterConte
208207
this._changeDetector.markForCheck();
209208
}
210209
});
211-
}
212-
213-
ngOnChanges() {
214210
this._inputsInitialized = true;
215211
}
216212

0 commit comments

Comments
 (0)