From edb46d0b6483274aff26ccadc02c10dce2b290f3 Mon Sep 17 00:00:00 2001 From: Josh Friend Date: Thu, 14 Jul 2016 14:39:19 -0400 Subject: [PATCH] feat(input): support autocapitalize and autocorrect attributes --- src/components/input/input.html | 2 ++ src/components/input/input.spec.ts | 40 ++++++++++++++++++++++++++++++ src/components/input/input.ts | 2 ++ 3 files changed, 44 insertions(+) diff --git a/src/components/input/input.html b/src/components/input/input.html index 8c526675fec2..33bd44808055 100644 --- a/src/components/input/input.html +++ b/src/components/input/input.html @@ -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" diff --git a/src/components/input/input.spec.ts b/src/components/input/input.spec.ts index 12ed39133310..ccfbf1d67041 100644 --- a/src/components/input/input.spec.ts +++ b/src/components/input/input.spec.ts @@ -273,6 +273,46 @@ describe('MdInput', function () { }); })); + it('supports the autoCorrect attribute', async(() => { + var template = ''; + + 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 = ''; + + 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 = ''; diff --git a/src/components/input/input.ts b/src/components/input/input.ts index 5985f39b31c0..f8b6b91409ec 100644 --- a/src/components/input/input.ts +++ b/src/components/input/input.ts @@ -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++}`;