Skip to content

Commit 215b92a

Browse files
committed
fix(material/checkbox): add aria-checked (#27970)
* fix(material/checkbox): add aria-checked * fix(material/checkbox): move aria-checked test (cherry picked from commit cc2f2c5)
1 parent d74e508 commit 215b92a

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/material/checkbox/checkbox.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
[attr.aria-label]="ariaLabel || null"
1212
[attr.aria-labelledby]="ariaLabelledby"
1313
[attr.aria-describedby]="ariaDescribedby"
14+
[attr.aria-checked]="indeterminate ? 'mixed' : null"
1415
[attr.name]="name"
1516
[attr.value]="value"
1617
[checked]="checked"

src/material/checkbox/checkbox.spec.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ describe('MDC-based MatCheckbox', () => {
5555

5656
expect(checkboxInstance.checked).toBe(true);
5757
expect(inputElement.checked).toBe(true);
58+
expect(inputElement.hasAttribute('aria-checked'))
59+
.withContext('Expect aria-checked attribute to not be used')
60+
.toBe(false);
5861

5962
testComponent.isChecked = false;
6063
fixture.detectChanges();
@@ -103,9 +106,6 @@ describe('MDC-based MatCheckbox', () => {
103106

104107
expect(inputElement.checked).toBe(false);
105108
expect(inputElement.indeterminate).toBe(true);
106-
expect(inputElement.hasAttribute('aria-checked'))
107-
.withContext('Expect aria-checked attribute to not be used')
108-
.toBe(false);
109109

110110
testComponent.isIndeterminate = false;
111111
fixture.detectChanges();
@@ -145,9 +145,6 @@ describe('MDC-based MatCheckbox', () => {
145145
expect(inputElement.indeterminate).toBe(true);
146146
expect(inputElement.checked).toBe(true);
147147
expect(testComponent.isIndeterminate).toBe(true);
148-
expect(inputElement.hasAttribute('aria-checked'))
149-
.withContext('Expect aria-checked attribute to not be used')
150-
.toBe(false);
151148

152149
inputElement.click();
153150
fixture.detectChanges();

0 commit comments

Comments
 (0)