diff --git a/src/lib/input/input.spec.ts b/src/lib/input/input.spec.ts index 5e5c272a4df5..1935f556c69a 100644 --- a/src/lib/input/input.spec.ts +++ b/src/lib/input/input.spec.ts @@ -671,6 +671,11 @@ describe('MatInput without forms', () => { expect(formFieldEl.classList).toContain('mat-form-field-should-float'); })); + it('should not throw if a native select does not have options', fakeAsync(() => { + const fixture = createComponent(MatInputSelectWithoutOptions); + expect(() => fixture.detectChanges()).not.toThrow(); + })); + it('should never float the label when floatLabel is set to false', fakeAsync(() => { let fixture = createComponent(MatInputWithDynamicLabel); @@ -1933,6 +1938,15 @@ class MatInputSelectWithInnerHtml {} }) class MatInputWithCustomAccessor {} +@Component({ + template: ` + + + ` +}) +class MatInputSelectWithoutOptions {} + /** Custom component that never has a value. Used for testing the `MAT_INPUT_VALUE_ACCESSOR`. */ @Directive({ diff --git a/src/lib/input/input.ts b/src/lib/input/input.ts index e383ac5a0762..545f9fe8be5e 100644 --- a/src/lib/input/input.ts +++ b/src/lib/input/input.ts @@ -383,9 +383,10 @@ export class MatInput extends _MatInputMixinBase implements MatFormFieldControl< // a non-empty display value. For a `