fix(select) aria-labelledby (#7022)

aria-labelledby must not be in the DOM if it is empty
this causes accessability bugs.
This commit is contained in:
Marcelo Luz
2017-09-29 16:15:02 -04:00
committed by Andrew Seguin
parent 2129b7a7f9
commit 947d3e84d1
2 changed files with 10 additions and 1 deletions
+9
View File
@@ -1802,6 +1802,15 @@ describe('MatSelect', () => {
expect(select.getAttribute('aria-labelledby')).toBe('myLabelId');
});
it('should not have aria-labelledby in the DOM if it`s not specified', async(() => {
fixture.detectChanges();
fixture.whenStable().then(() => {
expect(select.hasAttribute('aria-labelledby')).toBeFalsy();
});
}));
it('should set the tabindex of the select to 0 by default', () => {
expect(select.getAttribute('tabindex')).toEqual('0');
});
+1 -1
View File
@@ -371,7 +371,7 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit,
@Input('aria-label') ariaLabel: string = '';
/** Input that can be used to specify the `aria-labelledby` attribute. */
@Input('aria-labelledby') ariaLabelledby: string = '';
@Input('aria-labelledby') ariaLabelledby: string;
/** Unique id of the element. */
@Input()