File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -152,7 +152,14 @@ export class MdInputDirective {
152
152
*/
153
153
@Output ( ) _placeholderChange = new EventEmitter < string > ( ) ;
154
154
155
- get empty ( ) { return ( this . value == null || this . value === '' ) && ! this . _isNeverEmpty ( ) ; }
155
+ get empty ( ) {
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
+ // TODO(mmalerba): Add e2e test for bad input case.
161
+ ! this . _isBadInput ( ) ;
162
+ }
156
163
157
164
private get _uid ( ) { return this . _cachedUid = this . _cachedUid || `md-input-${ nextUniqueId ++ } ` ; }
158
165
@@ -199,6 +206,10 @@ export class MdInputDirective {
199
206
200
207
private _isNeverEmpty ( ) { return this . _neverEmptyInputTypes . indexOf ( this . _type ) !== - 1 ; }
201
208
209
+ private _isBadInput ( ) {
210
+ return ( this . _elementRef . nativeElement as HTMLInputElement ) . validity . badInput ;
211
+ }
212
+
202
213
/** Determines if the component host is a textarea. If not recognizable it returns false. */
203
214
private _isTextarea ( ) {
204
215
let nativeElement = this . _elementRef . nativeElement ;
You can’t perform that action at this time.
0 commit comments