Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support autocapitalize and autocorrect attributes on md-input #858

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/components/input/input.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
[attr.aria-required]="ariaRequired"
[attr.aria-invalid]="ariaInvalid"
[attr.autocomplete]="autoComplete"
[attr.autocorrect]="autoCorrect"
[attr.autocapitalize]="autoCapitalize"
[autofocus]="autoFocus"
[disabled]="disabled"
[id]="inputId"
Expand Down
40 changes: 40 additions & 0 deletions src/components/input/input.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,46 @@ describe('MdInput', function () {
});
}));

it('supports the autoCorrect attribute', async(() => {
var template = '<md-input [autoCorrect]="autoCorrect"></md-input>';

builder.overrideTemplate(MdInputOptionalAttributeController, template)
.createAsync(MdInputOptionalAttributeController)
.then(fixture => {
fixture.detectChanges();

let input: MdInput = fixture.debugElement.query(By.directive(MdInput)).componentInstance;
let el: HTMLInputElement = fixture.debugElement.query(By.css('input')).nativeElement;

expect(el).not.toBeNull();
expect(el.getAttribute('autocorrect')).toBeNull();

input.autoCorrect = 'on';
fixture.detectChanges();
expect(el.getAttribute('autocorrect')).toEqual('on');
});
}));

it('supports the autoCapitalize attribute', async(() => {
var template = '<md-input [autoCapitalize]="autoCapitalize"></md-input>';

builder.overrideTemplate(MdInputOptionalAttributeController, template)
.createAsync(MdInputOptionalAttributeController)
.then(fixture => {
fixture.detectChanges();

let input: MdInput = fixture.debugElement.query(By.directive(MdInput)).componentInstance;
let el: HTMLInputElement = fixture.debugElement.query(By.css('input')).nativeElement;

expect(el).not.toBeNull();
expect(el.getAttribute('autocapitalize')).toBeNull();

input.autoCapitalize = 'on';
fixture.detectChanges();
expect(el.getAttribute('autocapitalize')).toEqual('on');
});
}));

it('supports the autoComplete attribute as an unbound attribute', async(() => {
var template = '<md-input autoComplete></md-input>';

Expand Down
2 changes: 2 additions & 0 deletions src/components/input/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ export class MdInput implements ControlValueAccessor, AfterContentInit, OnChange
@Input() hintLabel: string = '';

@Input() autoComplete: string;
@Input() autoCorrect: string;
@Input() autoCapitalize: string;
@Input() @BooleanFieldValue() autoFocus: boolean = false;
@Input() @BooleanFieldValue() disabled: boolean = false;
@Input() id: string = `md-input-${nextUniqueId++}`;
Expand Down