Skip to content

Commit

Permalink
fix(input): fix placeholder for number input with bad input.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalerba committed Dec 23, 2016
1 parent 98be993 commit f92be2a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/lib/input/input-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,21 @@ export class MdInputDirective implements AfterContentInit {
*/
@Output() _placeholderChange = new EventEmitter<string>();

get empty() { return (this.value == null || this.value === '') && !this._isNeverEmpty(); }
get empty() {
if (this._isNeverEmpty()) {
return false;
}
if (this.value == null || this.value === '') {
// Check if this is an <input> element that contains bad input.
// If so, we know that it only appears empty because the value failed to parse.
if (this._elementRef.nativeElement instanceof HTMLInputElement &&
this._elementRef.nativeElement.validity.badInput) {
return false;
}
return true;
}
return false;
}

focused = false;

Expand Down

0 comments on commit f92be2a

Please sign in to comment.