fix(input): add aria-required to inputs (#8034)

This commit is contained in:
Jeremy Elbourn
2017-11-10 11:14:06 -08:00
committed by Joey Perrott
parent bc8560e495
commit 8178d6f70d
2 changed files with 18 additions and 0 deletions
+17
View File
@@ -238,6 +238,23 @@ describe('MatInput without forms', function () {
expect(labelElement.getAttribute('aria-owns')).toBe(inputElement.id);
});
it('should add aria-required reflecting the required state', () => {
const fixture = TestBed.createComponent(MatInputWithRequired);
fixture.detectChanges();
const inputElement: HTMLInputElement =
fixture.debugElement.query(By.css('input')).nativeElement;
expect(inputElement.getAttribute('aria-required'))
.toBe('false', 'Expected aria-required to reflect required state of false');
fixture.componentInstance.required = true;
fixture.detectChanges();
expect(inputElement.getAttribute('aria-required'))
.toBe('true', 'Expected aria-required to reflect required state of true');
});
it('should not overwrite existing id', () => {
let fixture = TestBed.createComponent(MatInputWithId);
fixture.detectChanges();
+1
View File
@@ -59,6 +59,7 @@ let nextUniqueId = 0;
'[readonly]': 'readonly',
'[attr.aria-describedby]': '_ariaDescribedby || null',
'[attr.aria-invalid]': 'errorState',
'[attr.aria-required]': 'required.toString()',
'(blur)': '_focusChanged(false)',
'(focus)': '_focusChanged(true)',
'(input)': '_onInput()',