Skip to content

fix(input): inaccurate textarea check during server-side render #10467

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
Mar 27, 2018
Merged
Show file tree
Hide file tree
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
10 changes: 2 additions & 8 deletions src/lib/input/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,15 +328,9 @@ export class MatInput extends _MatInputMixinBase implements MatFormFieldControl<
return validity && validity.badInput;
}

/** Determines if the component host is a textarea. If not recognizable it returns false. */
/** Determines if the component host is a textarea. */
protected _isTextarea() {
let nativeElement = this._elementRef.nativeElement;

// In Universal, we don't have access to `nodeName`, but the same can be achieved with `name`.
// Note that this shouldn't be necessary once Angular switches to an API that resembles the
// DOM closer.
let nodeName = this._platform.isBrowser ? nativeElement.nodeName : nativeElement.name;
return nodeName ? nodeName.toLowerCase() === 'textarea' : false;
return this._elementRef.nativeElement.nodeName.toLowerCase() === 'textarea';
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/universal-app/kitchen-sink/kitchen-sink.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ <h2>Icon</h2>
<h2>Input</h2>

<mat-form-field floatLabel="never">
<input matInput placeholder="name">
<input matInput placeholder="name" type="text">
</mat-form-field>

<mat-form-field>
<textarea matInput placeholder="description"></textarea>
</mat-form-field>

<mat-form-field>
Expand Down