mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
fix(checkbox): setting blank aria-label by default (#10281)
Fixes the checkbox adding a blank `aria-label` to the underlying input element by default.
This commit is contained in:
committed by
Jeremy Elbourn
parent
26ee3e77fc
commit
c12d7c473e
@@ -11,7 +11,7 @@
|
||||
[attr.name]="name"
|
||||
[tabIndex]="tabIndex"
|
||||
[indeterminate]="indeterminate"
|
||||
[attr.aria-label]="ariaLabel"
|
||||
[attr.aria-label]="ariaLabel || null"
|
||||
[attr.aria-labelledby]="ariaLabelledby"
|
||||
[attr.aria-checked]="_getAriaChecked()"
|
||||
(change)="_onInteractionEvent($event)"
|
||||
|
||||
@@ -701,7 +701,7 @@ describe('MatCheckbox', () => {
|
||||
}));
|
||||
});
|
||||
|
||||
describe('with provided aria-label ', () => {
|
||||
describe('aria-label ', () => {
|
||||
let checkboxDebugElement: DebugElement;
|
||||
let checkboxNativeElement: HTMLElement;
|
||||
let inputElement: HTMLInputElement;
|
||||
@@ -715,6 +715,13 @@ describe('MatCheckbox', () => {
|
||||
fixture.detectChanges();
|
||||
expect(inputElement.getAttribute('aria-label')).toBe('Super effective');
|
||||
});
|
||||
|
||||
it('should not set the aria-label attribute if no value is provided', () => {
|
||||
fixture = TestBed.createComponent(SingleCheckbox);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(fixture.nativeElement.querySelector('input').hasAttribute('aria-label')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('with provided aria-labelledby ', () => {
|
||||
|
||||
Reference in New Issue
Block a user