Skip to content

Commit 9749bc1

Browse files
committed
fix prerender and input test
1 parent 8de875b commit 9749bc1

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
@@ -19,7 +19,7 @@ import {
1919
Inject,
2020
Input,
2121
Optional,
22-
QueryList,
22+
QueryList, Renderer2,
2323
ViewChild,
2424
ViewEncapsulation,
2525
} from '@angular/core';
@@ -151,7 +151,9 @@ export class MdFormField implements AfterViewInit, AfterContentInit, AfterConten
151151
@ContentChildren(MdSuffix) _suffixChildren: QueryList<MdSuffix>;
152152

153153
constructor(
154-
public _elementRef: ElementRef, private _changeDetectorRef: ChangeDetectorRef,
154+
public _elementRef: ElementRef,
155+
private _renderer: Renderer2,
156+
private _changeDetectorRef: ChangeDetectorRef,
155157
@Optional() @Inject(MD_PLACEHOLDER_GLOBAL_OPTIONS) placeholderOptions: PlaceholderOptions) {
156158
this._placeholderOptions = placeholderOptions ? placeholderOptions : {};
157159
this.floatPlaceholder = this._placeholderOptions.float || 'auto';
@@ -160,8 +162,8 @@ export class MdFormField implements AfterViewInit, AfterContentInit, AfterConten
160162
ngAfterContentInit() {
161163
this._validateControlChild();
162164
if (this._control.controlType) {
163-
this._elementRef.nativeElement.classList.add(
164-
`mat-form-field-type-${this._control.controlType}`);
165+
this._renderer.addClass(
166+
this._elementRef.nativeElement, `mat-form-field-type-${this._control.controlType}`);
165167
}
166168

167169
// 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)