Skip to content

Commit

Permalink
addressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalerba committed Jan 4, 2017
1 parent f92be2a commit 3f4d382
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/lib/input/input-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,11 @@ export class MdInputDirective implements AfterContentInit {
@Output() _placeholderChange = new EventEmitter<string>();

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;
return !this._isNeverEmpty() &&
(this.value == null || this.value === '') &&
// Check if the input contains bad input. If so, we know that it only appears empty because
// the value failed to parse. From the user's perspective it is not empty.
!this._isBadInput();
}

focused = false;
Expand Down Expand Up @@ -188,6 +180,10 @@ export class MdInputDirective implements AfterContentInit {
}

private _isNeverEmpty() { return this._neverEmptyInputTypes.indexOf(this._type) != -1; }

private _isBadInput() {
return (this._elementRef.nativeElement as HTMLInputElement).validity.badInput;
}
}


Expand Down

0 comments on commit 3f4d382

Please sign in to comment.