Skip to content

Commit e043074

Browse files
committed
fix prerender and input test
1 parent db908c6 commit e043074

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/lib/form-field/form-field.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
Inject,
2323
Input,
2424
Optional,
25-
QueryList,
25+
QueryList, Renderer2,
2626
ViewChild,
2727
ViewEncapsulation,
2828
} from '@angular/core';
@@ -159,7 +159,9 @@ export class MdFormField implements AfterViewInit, AfterContentInit, AfterConten
159159
@ContentChildren(MdSuffix) _suffixChildren: QueryList<MdSuffix>;
160160

161161
constructor(
162-
public _elementRef: ElementRef, private _changeDetectorRef: ChangeDetectorRef,
162+
public _elementRef: ElementRef,
163+
private _renderer: Renderer2,
164+
private _changeDetectorRef: ChangeDetectorRef,
163165
@Optional() @Inject(MD_PLACEHOLDER_GLOBAL_OPTIONS) placeholderOptions: PlaceholderOptions) {
164166
this._placeholderOptions = placeholderOptions ? placeholderOptions : {};
165167
this.floatPlaceholder = this._placeholderOptions.float || 'auto';
@@ -168,8 +170,8 @@ export class MdFormField implements AfterViewInit, AfterContentInit, AfterConten
168170
ngAfterContentInit() {
169171
this._validateControlChild();
170172
if (this._control.controlType) {
171-
this._elementRef.nativeElement.classList.add(
172-
`mat-form-field-type-${this._control.controlType}`);
173+
this._renderer.addClass(
174+
this._elementRef.nativeElement, `mat-form-field-type-${this._control.controlType}`);
173175
}
174176

175177
// Subscribe to changes in the child control state in order to update the form field UI.

src/lib/input/input.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,7 @@ describe('MdInput without forms', function () {
196196
expect(labelEl.classList).not.toContain('mat-form-field-float');
197197
}));
198198

199-
/* TODO(mmalerba): investigate expression changed after checked.
200-
fit('should not be empty when the value set before view init', async(() => {
199+
it('should not be empty when the value set before view init', async(() => {
201200
let fixture = TestBed.createComponent(MdInputWithValueBinding);
202201
fixture.detectChanges();
203202

@@ -210,7 +209,7 @@ describe('MdInput without forms', function () {
210209
fixture.detectChanges();
211210

212211
expect(placeholderEl.classList).toContain('mat-form-field-empty');
213-
}));*/
212+
}));
214213

215214
it('should add id', () => {
216215
let fixture = TestBed.createComponent(MdInputTextTestController);

src/lib/input/input.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ export class MdInput implements MdFormFieldControl<any>, OnChanges, OnDestroy, D
132132
@Input() errorStateMatcher: ErrorStateMatcher;
133133

134134
/** The input element's value. */
135+
@Input()
135136
get value() { return this._elementRef.nativeElement.value; }
136137
set value(value: string) {
137138
if (value !== this.value) {

0 commit comments

Comments
 (0)