mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
fix(input): adds support for name property for input element (#452)
closes #446
This commit is contained in:
committed by
Jeremy Elbourn
parent
601204d810
commit
f53ffdbab2
@@ -27,6 +27,7 @@
|
||||
[attr.step]="step"
|
||||
[attr.tabindex]="tabIndex"
|
||||
[type]="type"
|
||||
[attr.name]="name"
|
||||
(focus)="handleFocus($event)"
|
||||
(blur)="handleBlur($event)"
|
||||
[(ngModel)]="value"
|
||||
|
||||
@@ -645,6 +645,16 @@ export function main() {
|
||||
})();
|
||||
});
|
||||
});
|
||||
|
||||
it('supports a name attribute', () => {
|
||||
return builder.createAsync(MdInputWithNameTestController).then(fixture => {
|
||||
const inputElement: HTMLInputElement = fixture.debugElement.query(By.css('input'))
|
||||
.nativeElement;
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(inputElement.name).toBe('some-name');
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -814,3 +824,12 @@ class MdInputWithBlurAndFocusEvents {
|
||||
directives: [MdInput]
|
||||
})
|
||||
class MdInputOptionalAttributeController {}
|
||||
|
||||
@Component({
|
||||
selector: 'test-input-controller',
|
||||
template: `
|
||||
<md-input name="some-name"></md-input>
|
||||
`,
|
||||
directives: [MdInput]
|
||||
})
|
||||
class MdInputWithNameTestController {}
|
||||
|
||||
@@ -155,6 +155,7 @@ export class MdInput implements ControlValueAccessor, AfterContentInit, OnChange
|
||||
@Input() step: number;
|
||||
@Input() tabIndex: number;
|
||||
@Input() type: string = 'text';
|
||||
@Input() name: string = null;
|
||||
|
||||
private _blurEmitter: EventEmitter<FocusEvent> = new EventEmitter<FocusEvent>();
|
||||
private _focusEmitter: EventEmitter<FocusEvent> = new EventEmitter<FocusEvent>();
|
||||
|
||||
Reference in New Issue
Block a user