Commit f85c914
committed
fix(template-require-mandatory-role-attributes): use classifyAttribute (rows i2, h6, h9, h10)
Two bugs fixed; both stem from AST-based classification ignoring runtime
rendering.
Bug 1 — bare-mustache string-literal role ignored (i2 analog).
Before: getStaticRolesFromElement only recognized role attributes whose
value was a `GlimmerTextNode`. The form `role={{"option"}}` (which renders
`role="option"` per the doc's i2-analog row — bare-mustache string literals
never coerce) was treated as dynamic and silently skipped, so the rule
never validated required ARIA attributes for it.
After: getStaticRolesFromElement uses classifyAttribute. Static text,
bare-string-literal mustache, and concat with all-literal parts (i1, i2,
i3 analogs) all resolve to the same string and feed into role-token
splitting.
Bug 2 — bare-mustache falsy aria attribute counted as satisfying required-aria (h6, h9, h10).
Before: required-ARIA satisfaction was checked by AST attribute name
presence — `<div role="option" aria-selected={{false}} />` was treated as
having aria-selected even though Glimmer OMITS the attribute at runtime
per doc rows h6 (`{{false}}`), h9 (`{{null}}`), h10 (`{{undefined}}`).
This was *also* encoded as a passing valid fixture, locking the bug in.
After: the aria-attribute filter excludes attributes whose
`classifyAttribute(attr).presence === 'absent'`. The previously-passing
fixture moved from valid to invalid; replaced with positive cases that
use static aria values (`aria-selected="true"` / `"false"`) and the
new i2 role classification.
Test coverage:
- Valid (new): `<div role={{"option"}} aria-selected="true" />`
- Invalid (new): `<div role="option" aria-selected={{false}} />` (h6)
- Invalid (new): `<div role="option" aria-selected={{null}} />` (h9)
- Invalid (new): `<div role={{"option"}} />` (i2 + missing aria)
- All variants in both GJS and HBS suites.
- Replaced the bug-encoding fixture (valid `<div role="option" aria-selected={{false}} />`) with `aria-selected="true"`/`"false"` static-value cases preserving the original "aria-selected satisfies role=option" intent.
106 tests pass. Doc rows cited: i1, i2, i3 (role classification); h6, h9, h10 (aria-* falsy-coercion).1 parent de1838b commit f85c914
2 files changed
Lines changed: 79 additions & 6 deletions
File tree
- lib/rules
- tests/lib/rules
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
| 5 | + | |
3 | 6 | | |
4 | 7 | | |
5 | 8 | | |
6 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
7 | 18 | | |
8 | 19 | | |
9 | | - | |
10 | | - | |
11 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
12 | 23 | | |
13 | 24 | | |
14 | 25 | | |
| |||
231 | 242 | | |
232 | 243 | | |
233 | 244 | | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
234 | 252 | | |
235 | | - | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
236 | 258 | | |
237 | 259 | | |
238 | 260 | | |
| |||
Lines changed: 53 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
16 | 24 | | |
17 | 25 | | |
18 | 26 | | |
| |||
74 | 82 | | |
75 | 83 | | |
76 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
77 | 108 | | |
78 | 109 | | |
79 | 110 | | |
| |||
246 | 277 | | |
247 | 278 | | |
248 | 279 | | |
249 | | - | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
250 | 284 | | |
251 | 285 | | |
252 | 286 | | |
| |||
285 | 319 | | |
286 | 320 | | |
287 | 321 | | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
288 | 339 | | |
289 | 340 | | |
290 | 341 | | |
| |||
0 commit comments