File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -152,7 +152,21 @@ 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
+ 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 ;
169
+ }
156
170
157
171
private get _uid ( ) { return this . _cachedUid = this . _cachedUid || `md-input-${ nextUniqueId ++ } ` ; }
158
172
You can’t perform that action at this time.
0 commit comments