Skip to content

Commit

Permalink
fix(checkbox): setting blank aria-label by default (#10281)
Browse files Browse the repository at this point in the history
Fixes the checkbox adding a blank `aria-label` to the underlying input element by default.
  • Loading branch information
crisbeto authored and jelbourn committed Mar 9, 2018
1 parent 26ee3e7 commit c12d7c4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib/checkbox/checkbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
9 changes: 8 additions & 1 deletion src/lib/checkbox/checkbox.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ describe('MatCheckbox', () => {
}));
});

describe('with provided aria-label ', () => {
describe('aria-label ', () => {
let checkboxDebugElement: DebugElement;
let checkboxNativeElement: HTMLElement;
let inputElement: HTMLInputElement;
Expand All @@ -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 ', () => {
Expand Down

0 comments on commit c12d7c4

Please sign in to comment.