File tree Expand file tree Collapse file tree 1 file changed +9
-13
lines changed Expand file tree Collapse file tree 1 file changed +9
-13
lines changed Original file line number Diff line number Diff line change @@ -125,19 +125,11 @@ export class MdInputDirective implements AfterContentInit {
125
125
@Output ( ) _placeholderChange = new EventEmitter < string > ( ) ;
126
126
127
127
get empty ( ) {
128
- if ( this . _isNeverEmpty ( ) ) {
129
- return false ;
130
- }
131
- if ( this . value == null || this . value === '' ) {
132
- // Check if this is an <input> element that contains bad input.
133
- // If so, we know that it only appears empty because the value failed to parse.
134
- if ( this . _elementRef . nativeElement instanceof HTMLInputElement &&
135
- this . _elementRef . nativeElement . validity . badInput ) {
136
- return false ;
137
- }
138
- return true ;
139
- }
140
- return false ;
128
+ return ! this . _isNeverEmpty ( ) &&
129
+ ( this . value == null || this . value === '' ) &&
130
+ // Check if the input contains bad input. If so, we know that it only appears empty because
131
+ // the value failed to parse. From the user's perspective it is not empty.
132
+ ! this . _isBadInput ( ) ;
141
133
}
142
134
143
135
focused = false ;
@@ -188,6 +180,10 @@ export class MdInputDirective implements AfterContentInit {
188
180
}
189
181
190
182
private _isNeverEmpty ( ) { return this . _neverEmptyInputTypes . indexOf ( this . _type ) != - 1 ; }
183
+
184
+ private _isBadInput ( ) {
185
+ return ( this . _elementRef . nativeElement as HTMLInputElement ) . validity . badInput ;
186
+ }
191
187
}
192
188
193
189
You can’t perform that action at this time.
0 commit comments