Skip to content

Commit

Permalink
feat(input): support autocapitalize and autocorrect attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Friend committed Jul 14, 2016
1 parent 04d1c80 commit edb46d0
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
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

0 comments on commit edb46d0

Please sign in to comment.