Skip to content

Commit

Permalink
fix(input): adds support for name property for input element (#452)
Browse files Browse the repository at this point in the history
closes #446
  • Loading branch information
robertmesserle authored and jelbourn committed May 19, 2016
1 parent 601204d commit f53ffdb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/components/input/input.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
[attr.step]="step"
[attr.tabindex]="tabIndex"
[type]="type"
[attr.name]="name"
(focus)="handleFocus($event)"
(blur)="handleBlur($event)"
[(ngModel)]="value"
Expand Down
19 changes: 19 additions & 0 deletions src/components/input/input.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
});
}

Expand Down Expand Up @@ -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 {}
1 change: 1 addition & 0 deletions src/components/input/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>();
Expand Down

0 comments on commit f53ffdb

Please sign in to comment.