Commit bcadc82
committed
fix(template-no-invalid-aria-attributes): absorb allowundefined handling into validateByType
Removes the top-level string-"undefined" short-circuit in `isValidAriaValue`
(previously a two-layer dance: a token-type precheck then a boolean-ish
short-circuit). Absorbs the `allowundefined` handling directly into
`validateByType` via a new `allowsUndefinedLiteral(attrDef, value)` helper
that honors aria-query's convention for the 4 boolean-type attrs that
encode "string 'undefined' is spec-valid": aria-expanded, aria-hidden,
aria-grabbed, aria-selected.
## Before/after — same outcome, cleaner structure
| Attribute | aria-query type / allowundefined | `"undefined"` string accepted? |
|---|---|---|
| aria-orientation | token / (unset) with `'undefined'` in values | yes — via token-values check |
| aria-expanded | boolean / true | yes — via allowundefined |
| aria-hidden | boolean / true | yes — via allowundefined |
| aria-grabbed | boolean / true | yes — via allowundefined |
| aria-selected | boolean / true | yes — via allowundefined |
| aria-pressed | tristate / (unset) | NO — no allowundefined flag |
| aria-checked | tristate / (unset) | NO — no allowundefined flag |
All behavior preserved; just structured so that validity decisions
happen in one place.
## Why keep the allowundefined path at all
The 4 boolean-type attrs with `allowundefined: true` have spec-valid
`"undefined"` values per WAI-ARIA 1.2 (e.g. aria-expanded accepts
true/false/undefined). aria-query encodes this. Peers (jsx-a11y,
lit-a11y, angular-eslint) effectively reject `aria-expanded="undefined"`
because their `allowundefined` branch only fires on JS undefined, not
the string. That's a peer bug; our path keeps us spec-compliant.
Tests added for each of the 4 allowundefined attrs; new negative test
for `aria-pressed="undefined"` (tristate without allowundefined) pins
the correct rejection path.1 parent 24882a3 commit bcadc82
2 files changed
Lines changed: 76 additions & 9 deletions
File tree
- lib/rules
- tests/lib/rules
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
19 | 23 | | |
20 | | - | |
21 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
22 | 27 | | |
23 | | - | |
24 | 28 | | |
25 | 29 | | |
26 | 30 | | |
| |||
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
48 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
49 | 55 | | |
50 | 56 | | |
51 | 57 | | |
| |||
60 | 66 | | |
61 | 67 | | |
62 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
63 | 77 | | |
64 | 78 | | |
65 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
34 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
35 | 52 | | |
36 | 53 | | |
37 | 54 | | |
| |||
121 | 138 | | |
122 | 139 | | |
123 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
124 | 153 | | |
125 | 154 | | |
126 | 155 | | |
| |||
149 | 178 | | |
150 | 179 | | |
151 | 180 | | |
| 181 | + | |
152 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
153 | 195 | | |
154 | 196 | | |
155 | 197 | | |
| |||
223 | 265 | | |
224 | 266 | | |
225 | 267 | | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
226 | 279 | | |
227 | 280 | | |
0 commit comments