Skip to content

Commit dda1d04

Browse files
crisbetojosephperrott
authored andcommitted
fix(input): inaccurate textarea check during server-side render (#10467)
A while ago we added a check to the `_isTextarea` method that accounted for the old renderer's non-standard API. These changes remove that check, because it isn't accurate anymore with the new renderer.
1 parent 946fd84 commit dda1d04

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/lib/input/input.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -328,15 +328,9 @@ export class MatInput extends _MatInputMixinBase implements MatFormFieldControl<
328328
return validity && validity.badInput;
329329
}
330330

331-
/** Determines if the component host is a textarea. If not recognizable it returns false. */
331+
/** Determines if the component host is a textarea. */
332332
protected _isTextarea() {
333-
let nativeElement = this._elementRef.nativeElement;
334-
335-
// In Universal, we don't have access to `nodeName`, but the same can be achieved with `name`.
336-
// Note that this shouldn't be necessary once Angular switches to an API that resembles the
337-
// DOM closer.
338-
let nodeName = this._platform.isBrowser ? nativeElement.nodeName : nativeElement.name;
339-
return nodeName ? nodeName.toLowerCase() === 'textarea' : false;
333+
return this._elementRef.nativeElement.nodeName.toLowerCase() === 'textarea';
340334
}
341335

342336
/**

src/universal-app/kitchen-sink/kitchen-sink.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,11 @@ <h2>Icon</h2>
112112
<h2>Input</h2>
113113

114114
<mat-form-field floatLabel="never">
115-
<input matInput placeholder="name">
115+
<input matInput placeholder="name" type="text">
116+
</mat-form-field>
117+
118+
<mat-form-field>
119+
<textarea matInput placeholder="description"></textarea>
116120
</mat-form-field>
117121

118122
<mat-form-field>

0 commit comments

Comments
 (0)