Commit 7e141bf
committed
fix(template-require-mandatory-role-attributes): recognize native aria-checked from <input type=checkbox|radio>
The rule required an explicit `aria-checked` on every element with a
role that needs it — even when the host element is a semantic form
control that contributes the state natively.
WAI-ARIA APG documents <input type="checkbox" role="switch"> as an
accessible switch pattern (see https://www.w3.org/WAI/ARIA/apg/patterns/switch/);
the <input>'s native checked state maps to aria-checked.
Fix: when the host is <input type="checkbox"> or <input type="radio">
and the role is one of {checkbox, menuitemcheckbox, menuitemradio,
radio, switch}, treat aria-checked as satisfied.
Matches eslint-plugin-jsx-a11y's role-has-required-aria-props, which
uses axobject-query's isSemanticRoleElement to skip the check for
element+role combinations where the native element already exposes the
required state. Our implementation covers the common cases without
pulling in the axobject-query dependency.
Five new test cases added covering the documented pattern. Rule doc
updated with an explicit example and an APG link.1 parent 24882a3 commit 7e141bf
3 files changed
Lines changed: 68 additions & 5 deletions
File tree
- docs/rules
- lib/rules
- tests/lib/rules
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
34 | 39 | | |
35 | 40 | | |
36 | 41 | | |
37 | 42 | | |
38 | 43 | | |
39 | 44 | | |
| 45 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
32 | 63 | | |
33 | 64 | | |
34 | 65 | | |
35 | 66 | | |
36 | 67 | | |
37 | 68 | | |
38 | 69 | | |
39 | | - | |
40 | | - | |
41 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
42 | 79 | | |
43 | 80 | | |
44 | 81 | | |
| |||
93 | 130 | | |
94 | 131 | | |
95 | 132 | | |
96 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
97 | 138 | | |
98 | 139 | | |
99 | 140 | | |
| |||
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
28 | 37 | | |
29 | 38 | | |
30 | 39 | | |
| |||
105 | 114 | | |
106 | 115 | | |
107 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
108 | 124 | | |
109 | 125 | | |
110 | 126 | | |
| |||
0 commit comments