Skip to content

Commit 3f4d382

Browse files
committed
addressed comments
1 parent f92be2a commit 3f4d382

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

src/lib/input/input-container.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -125,19 +125,11 @@ export class MdInputDirective implements AfterContentInit {
125125
@Output() _placeholderChange = new EventEmitter<string>();
126126

127127
get empty() {
128-
if (this._isNeverEmpty()) {
129-
return false;
130-
}
131-
if (this.value == null || this.value === '') {
132-
// Check if this is an <input> element that contains bad input.
133-
// If so, we know that it only appears empty because the value failed to parse.
134-
if (this._elementRef.nativeElement instanceof HTMLInputElement &&
135-
this._elementRef.nativeElement.validity.badInput) {
136-
return false;
137-
}
138-
return true;
139-
}
140-
return false;
128+
return !this._isNeverEmpty() &&
129+
(this.value == null || this.value === '') &&
130+
// Check if the input contains bad input. If so, we know that it only appears empty because
131+
// the value failed to parse. From the user's perspective it is not empty.
132+
!this._isBadInput();
141133
}
142134

143135
focused = false;
@@ -188,6 +180,10 @@ export class MdInputDirective implements AfterContentInit {
188180
}
189181

190182
private _isNeverEmpty() { return this._neverEmptyInputTypes.indexOf(this._type) != -1; }
183+
184+
private _isBadInput() {
185+
return (this._elementRef.nativeElement as HTMLInputElement).validity.badInput;
186+
}
191187
}
192188

193189

0 commit comments

Comments
 (0)