@@ -96,10 +96,13 @@ export class MatInput extends _MatInputMixinBase implements MatFormFieldControl<
96
96
_ariaDescribedby : string ;
97
97
98
98
/** Whether the component is being rendered on the server. */
99
- _isServer = false ;
99
+ readonly _isServer : boolean ;
100
100
101
101
/** Whether the component is a native html select. */
102
- _isNativeSelect = false ;
102
+ readonly _isNativeSelect : boolean ;
103
+
104
+ /** Whether the component is a textarea. */
105
+ readonly _isTextarea : boolean ;
103
106
104
107
/**
105
108
* Implemented as part of MatFormFieldControl.
@@ -182,7 +185,7 @@ export class MatInput extends _MatInputMixinBase implements MatFormFieldControl<
182
185
// When using Angular inputs, developers are no longer able to set the properties on the native
183
186
// input element. To ensure that bindings for `type` work, we need to sync the setter
184
187
// with the native property. Textarea elements don't support the type property or attribute.
185
- if ( ! this . _isTextarea ( ) && getSupportedInputTypes ( ) . has ( this . _type ) ) {
188
+ if ( ! this . _isTextarea && getSupportedInputTypes ( ) . has ( this . _type ) ) {
186
189
( this . _elementRef . nativeElement as HTMLInputElement ) . type = this . _type ;
187
190
}
188
191
}
@@ -234,6 +237,7 @@ export class MatInput extends _MatInputMixinBase implements MatFormFieldControl<
234
237
super ( _defaultErrorStateMatcher , _parentForm , _parentFormGroup , ngControl ) ;
235
238
236
239
const element = this . _elementRef . nativeElement ;
240
+ const nodeName = element . nodeName . toLowerCase ( ) ;
237
241
238
242
// If no input value accessor was explicitly specified, use the element as the input value
239
243
// accessor.
@@ -264,7 +268,8 @@ export class MatInput extends _MatInputMixinBase implements MatFormFieldControl<
264
268
}
265
269
266
270
this . _isServer = ! this . _platform . isBrowser ;
267
- this . _isNativeSelect = element . nodeName . toLowerCase ( ) === 'select' ;
271
+ this . _isNativeSelect = nodeName === 'select' ;
272
+ this . _isTextarea = nodeName === 'textarea' ;
268
273
269
274
if ( this . _isNativeSelect ) {
270
275
this . controlType = ( element as HTMLSelectElement ) . multiple ? 'mat-native-select-multiple' :
@@ -344,11 +349,6 @@ export class MatInput extends _MatInputMixinBase implements MatFormFieldControl<
344
349
// FormsModule or ReactiveFormsModule, because Angular forms also listens to input events.
345
350
}
346
351
347
- /** Determines if the component host is a textarea. */
348
- _isTextarea ( ) {
349
- return this . _elementRef . nativeElement . nodeName . toLowerCase ( ) === 'textarea' ;
350
- }
351
-
352
352
/** Does some manual dirty checking on the native input `value` property. */
353
353
protected _dirtyCheckNativeValue ( ) {
354
354
const newValue = this . _elementRef . nativeElement . value ;
0 commit comments