Skip to content

chore: fix compilation error in form field #12907

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 30, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions src/lib/input/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export class MatInput extends _MatInputMixinBase implements MatFormFieldControl<
// input element. To ensure that bindings for `type` work, we need to sync the setter
// with the native property. Textarea elements don't support the type property or attribute.
if (!this._isTextarea() && getSupportedInputTypes().has(this._type)) {
this._elementRef.nativeElement.type = this._type;
(this._elementRef.nativeElement as HTMLInputElement).type = this._type;
}
}
protected _type = 'text';
Expand Down Expand Up @@ -221,16 +221,17 @@ export class MatInput extends _MatInputMixinBase implements MatFormFieldControl<
'week'
].filter(t => getSupportedInputTypes().has(t));

constructor(protected _elementRef: ElementRef<HTMLInputElement>,
protected _platform: Platform,
/** @docs-private */
@Optional() @Self() public ngControl: NgControl,
@Optional() _parentForm: NgForm,
@Optional() _parentFormGroup: FormGroupDirective,
_defaultErrorStateMatcher: ErrorStateMatcher,
@Optional() @Self() @Inject(MAT_INPUT_VALUE_ACCESSOR) inputValueAccessor: any,
private _autofillMonitor: AutofillMonitor,
ngZone: NgZone) {
constructor(
protected _elementRef: ElementRef<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>,
protected _platform: Platform,
/** @docs-private */
@Optional() @Self() public ngControl: NgControl,
@Optional() _parentForm: NgForm,
@Optional() _parentFormGroup: FormGroupDirective,
_defaultErrorStateMatcher: ErrorStateMatcher,
@Optional() @Self() @Inject(MAT_INPUT_VALUE_ACCESSOR) inputValueAccessor: any,
private _autofillMonitor: AutofillMonitor,
ngZone: NgZone) {
super(_defaultErrorStateMatcher, _parentForm, _parentFormGroup, ngControl);
// If no input value accessor was explicitly specified, use the element as the input value
// accessor.
Expand Down Expand Up @@ -372,8 +373,9 @@ export class MatInput extends _MatInputMixinBase implements MatFormFieldControl<
// For a single-selection `<select>`, the label should float when the selected option has
// a non-empty display value. For a `<select multiple>`, the label *always* floats to avoid
// overlapping the label with the options.
const selectElement = this._elementRef.nativeElement;
return selectElement.multiple || !this.empty || selectElement.options[0].label ||
const selectElement = this._elementRef.nativeElement as HTMLSelectElement;

return selectElement.multiple || !this.empty || !!selectElement.options[0].label ||
this.focused;
} else {
return this.focused || !this.empty;
Expand Down