Skip to content

Commit 1efd8f9

Browse files
committed
addressed comments
1 parent 03d694a commit 1efd8f9

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
@@ -153,19 +153,11 @@ export class MdInputDirective {
153153
@Output() _placeholderChange = new EventEmitter<string>();
154154

155155
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;
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+
!this._isBadInput();
169161
}
170162

171163
private get _uid() { return this._cachedUid = this._cachedUid || `md-input-${nextUniqueId++}`; }
@@ -213,6 +205,10 @@ export class MdInputDirective {
213205

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

208+
private _isBadInput() {
209+
return (this._elementRef.nativeElement as HTMLInputElement).validity.badInput;
210+
}
211+
216212
/** Determines if the component host is a textarea. If not recognizable it returns false. */
217213
private _isTextarea() {
218214
let nativeElement = this._elementRef.nativeElement;

0 commit comments

Comments
 (0)