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 @@ -153,19 +153,11 @@ export class MdInputDirective {
153
153
@Output ( ) _placeholderChange = new EventEmitter < string > ( ) ;
154
154
155
155
get empty ( ) {
156
- if ( this . _isNeverEmpty ( ) ) {
157
- return false ;
158
- }
159
- if ( this . value == null || this . value === '' ) {
160
- // Check if this is an <input> element that contains bad input.
161
- // If so, we know that it only appears empty because the value failed to parse.
162
- if ( this . _elementRef . nativeElement instanceof HTMLInputElement &&
163
- this . _elementRef . nativeElement . validity . badInput ) {
164
- return false ;
165
- }
166
- return true ;
167
- }
168
- return false ;
156
+ return ! this . _isNeverEmpty ( ) &&
157
+ ( this . value == null || this . value === '' ) &&
158
+ // Check if the input contains bad input. If so, we know that it only appears empty because
159
+ // the value failed to parse. From the user's perspective it is not empty.
160
+ ! this . _isBadInput ( ) ;
169
161
}
170
162
171
163
private get _uid ( ) { return this . _cachedUid = this . _cachedUid || `md-input-${ nextUniqueId ++ } ` ; }
@@ -213,6 +205,10 @@ export class MdInputDirective {
213
205
214
206
private _isNeverEmpty ( ) { return this . _neverEmptyInputTypes . indexOf ( this . _type ) !== - 1 ; }
215
207
208
+ private _isBadInput ( ) {
209
+ return ( this . _elementRef . nativeElement as HTMLInputElement ) . validity . badInput ;
210
+ }
211
+
216
212
/** Determines if the component host is a textarea. If not recognizable it returns false. */
217
213
private _isTextarea ( ) {
218
214
let nativeElement = this . _elementRef . nativeElement ;
You can’t perform that action at this time.
0 commit comments