From f53ffdbab2b05b120f51890ae1b4939509b8953f Mon Sep 17 00:00:00 2001 From: Robert Messerle Date: Wed, 18 May 2016 17:29:39 -0700 Subject: [PATCH] fix(input): adds support for name property for input element (#452) closes #446 --- src/components/input/input.html | 1 + src/components/input/input.spec.ts | 19 +++++++++++++++++++ src/components/input/input.ts | 1 + 3 files changed, 21 insertions(+) diff --git a/src/components/input/input.html b/src/components/input/input.html index e76d6f8f15eb..04262c419942 100644 --- a/src/components/input/input.html +++ b/src/components/input/input.html @@ -27,6 +27,7 @@ [attr.step]="step" [attr.tabindex]="tabIndex" [type]="type" + [attr.name]="name" (focus)="handleFocus($event)" (blur)="handleBlur($event)" [(ngModel)]="value" diff --git a/src/components/input/input.spec.ts b/src/components/input/input.spec.ts index 0b29ba0e72e0..3b7aeb167338 100644 --- a/src/components/input/input.spec.ts +++ b/src/components/input/input.spec.ts @@ -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: ` + + `, + directives: [MdInput] +}) +class MdInputWithNameTestController {} diff --git a/src/components/input/input.ts b/src/components/input/input.ts index a4507558e38f..01a00b9f39ef 100644 --- a/src/components/input/input.ts +++ b/src/components/input/input.ts @@ -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 = new EventEmitter(); private _focusEmitter: EventEmitter = new EventEmitter();