mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
fix(input): add aria-required to inputs (#8034)
This commit is contained in:
committed by
Joey Perrott
parent
bc8560e495
commit
8178d6f70d
@@ -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();
|
||||
|
||||
@@ -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()',
|
||||
|
||||
Reference in New Issue
Block a user