Skip to content

Commit f88b4a2

Browse files
committed
chore: fix compilation error in form field
Fixes a compilation error in the `matNativeControl` directive.
1 parent ac8ed31 commit f88b4a2

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/lib/input/input.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ export class MatInput extends _MatInputMixinBase implements MatFormFieldControl<
185185
// input element. To ensure that bindings for `type` work, we need to sync the setter
186186
// with the native property. Textarea elements don't support the type property or attribute.
187187
if (!this._isTextarea() && getSupportedInputTypes().has(this._type)) {
188-
this._elementRef.nativeElement.type = this._type;
188+
(this._elementRef.nativeElement as HTMLInputElement).type = this._type;
189189
}
190190
}
191191
protected _type = 'text';
@@ -221,7 +221,7 @@ export class MatInput extends _MatInputMixinBase implements MatFormFieldControl<
221221
'week'
222222
].filter(t => getSupportedInputTypes().has(t));
223223

224-
constructor(protected _elementRef: ElementRef<HTMLInputElement>,
224+
constructor(protected _elementRef: ElementRef<HTMLInputElement | HTMLSelectElement>,
225225
protected _platform: Platform,
226226
/** @docs-private */
227227
@Optional() @Self() public ngControl: NgControl,
@@ -372,8 +372,9 @@ export class MatInput extends _MatInputMixinBase implements MatFormFieldControl<
372372
// For a single-selection `<select>`, the label should float when the selected option has
373373
// a non-empty display value. For a `<select multiple>`, the label *always* floats to avoid
374374
// overlapping the label with the options.
375-
const selectElement = this._elementRef.nativeElement;
376-
return selectElement.multiple || !this.empty || selectElement.options[0].label ||
375+
const selectElement = this._elementRef.nativeElement as HTMLSelectElement;
376+
377+
return selectElement.multiple || !this.empty || !!selectElement.options[0].label ||
377378
this.focused;
378379
} else {
379380
return this.focused || !this.empty;

0 commit comments

Comments
 (0)