Skip to content

Commit f53ffdb

Browse files
robertmesserlejelbourn
authored andcommitted
fix(input): adds support for name property for input element (#452)
closes #446
1 parent 601204d commit f53ffdb

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

src/components/input/input.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
[attr.step]="step"
2828
[attr.tabindex]="tabIndex"
2929
[type]="type"
30+
[attr.name]="name"
3031
(focus)="handleFocus($event)"
3132
(blur)="handleBlur($event)"
3233
[(ngModel)]="value"

src/components/input/input.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,16 @@ export function main() {
645645
})();
646646
});
647647
});
648+
649+
it('supports a name attribute', () => {
650+
return builder.createAsync(MdInputWithNameTestController).then(fixture => {
651+
const inputElement: HTMLInputElement = fixture.debugElement.query(By.css('input'))
652+
.nativeElement;
653+
fixture.detectChanges();
654+
655+
expect(inputElement.name).toBe('some-name');
656+
});
657+
});
648658
});
649659
}
650660

@@ -814,3 +824,12 @@ class MdInputWithBlurAndFocusEvents {
814824
directives: [MdInput]
815825
})
816826
class MdInputOptionalAttributeController {}
827+
828+
@Component({
829+
selector: 'test-input-controller',
830+
template: `
831+
<md-input name="some-name"></md-input>
832+
`,
833+
directives: [MdInput]
834+
})
835+
class MdInputWithNameTestController {}

src/components/input/input.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ export class MdInput implements ControlValueAccessor, AfterContentInit, OnChange
155155
@Input() step: number;
156156
@Input() tabIndex: number;
157157
@Input() type: string = 'text';
158+
@Input() name: string = null;
158159

159160
private _blurEmitter: EventEmitter<FocusEvent> = new EventEmitter<FocusEvent>();
160161
private _focusEmitter: EventEmitter<FocusEvent> = new EventEmitter<FocusEvent>();

0 commit comments

Comments
 (0)