Skip to content

Commit b2471f2

Browse files
joshfriendkara
authored andcommitted
feat(input): support autocapitalize and autocorrect attributes (#858)
1 parent 22254dc commit b2471f2

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

src/components/input/input.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
[attr.aria-required]="ariaRequired"
1414
[attr.aria-invalid]="ariaInvalid"
1515
[attr.autocomplete]="autoComplete"
16+
[attr.autocorrect]="autoCorrect"
17+
[attr.autocapitalize]="autoCapitalize"
1618
[autofocus]="autoFocus"
1719
[disabled]="disabled"
1820
[id]="inputId"

src/components/input/input.spec.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,46 @@ describe('MdInput', function () {
273273
});
274274
}));
275275

276+
it('supports the autoCorrect attribute', async(() => {
277+
var template = '<md-input [autoCorrect]="autoCorrect"></md-input>';
278+
279+
builder.overrideTemplate(MdInputOptionalAttributeController, template)
280+
.createAsync(MdInputOptionalAttributeController)
281+
.then(fixture => {
282+
fixture.detectChanges();
283+
284+
let input: MdInput = fixture.debugElement.query(By.directive(MdInput)).componentInstance;
285+
let el: HTMLInputElement = fixture.debugElement.query(By.css('input')).nativeElement;
286+
287+
expect(el).not.toBeNull();
288+
expect(el.getAttribute('autocorrect')).toBeNull();
289+
290+
input.autoCorrect = 'on';
291+
fixture.detectChanges();
292+
expect(el.getAttribute('autocorrect')).toEqual('on');
293+
});
294+
}));
295+
296+
it('supports the autoCapitalize attribute', async(() => {
297+
var template = '<md-input [autoCapitalize]="autoCapitalize"></md-input>';
298+
299+
builder.overrideTemplate(MdInputOptionalAttributeController, template)
300+
.createAsync(MdInputOptionalAttributeController)
301+
.then(fixture => {
302+
fixture.detectChanges();
303+
304+
let input: MdInput = fixture.debugElement.query(By.directive(MdInput)).componentInstance;
305+
let el: HTMLInputElement = fixture.debugElement.query(By.css('input')).nativeElement;
306+
307+
expect(el).not.toBeNull();
308+
expect(el.getAttribute('autocapitalize')).toBeNull();
309+
310+
input.autoCapitalize = 'on';
311+
fixture.detectChanges();
312+
expect(el.getAttribute('autocapitalize')).toEqual('on');
313+
});
314+
}));
315+
276316
it('supports the autoComplete attribute as an unbound attribute', async(() => {
277317
var template = '<md-input autoComplete></md-input>';
278318

src/components/input/input.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ export class MdInput implements ControlValueAccessor, AfterContentInit, OnChange
144144
@Input() hintLabel: string = '';
145145

146146
@Input() autoComplete: string;
147+
@Input() autoCorrect: string;
148+
@Input() autoCapitalize: string;
147149
@Input() @BooleanFieldValue() autoFocus: boolean = false;
148150
@Input() @BooleanFieldValue() disabled: boolean = false;
149151
@Input() id: string = `md-input-${nextUniqueId++}`;

0 commit comments

Comments
 (0)