Commit a1c2816
committed
fix: treat aria-hidden={{true}} as an explicit escape hatch in click-events check
Premise: jsx-a11y accepts `aria-hidden={true}` (JSX boolean literal) as a
static opt-out of the click-events-have-key-events check. The HBS analog
is `aria-hidden={{true}}` — a GlimmerMustacheStatement whose path is a
GlimmerBooleanLiteral with value `true`. The previous
`isHiddenFromScreenReader` helper happened to treat this correctly, but
only because it also treated ANY mustache value as truthy (e.g.
`aria-hidden={{this.maybeHidden}}` would silence the rule as if the
element were guaranteed hidden). That is too permissive: a dynamic value
can't be proven hidden at lint time, so the rule should still fire.
Conclusion: rewrite the aria-hidden check to distinguish the two shapes
explicitly.
- `isHiddenFromScreenReader` now only returns true for:
- GlimmerTextNode value with chars `""` (bare attribute) or `"true"`
(case-insensitive, trimmed).
- GlimmerMustacheStatement whose `path` is a GlimmerBooleanLiteral
with value `true` — i.e. the literal `{{true}}`.
- Other mustache shapes (path references, helper calls) are now treated
as dynamic/unknown, so the rule fires. Authors who want a static
escape hatch should write `aria-hidden` or `aria-hidden="true"` or
`aria-hidden={{true}}`.
- Tests added for the mustache-literal valid case and for the new
dynamic-mustache invalid cases (`{{false}}`, `{{this.x}}`).
- Audit fixture: adds `aria-hidden={{true}}` as explicit parity with
jsx-a11y's `aria-hidden={true}`.
Tracks PR #28 item G1 (escape-hatch awareness). Companion to the
master-side `template-no-invalid-interactive` fix.1 parent dbfcbad commit a1c2816
3 files changed
Lines changed: 43 additions & 3 deletions
File tree
- lib/rules
- tests
- audit/click-events-have-key-events
- lib/rules
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
40 | 51 | | |
41 | 52 | | |
42 | 53 | | |
43 | | - | |
44 | | - | |
45 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
46 | 66 | | |
47 | 67 | | |
48 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
55 | 58 | | |
56 | 59 | | |
57 | 60 | | |
| |||
290 | 293 | | |
291 | 294 | | |
292 | 295 | | |
| 296 | + | |
293 | 297 | | |
294 | 298 | | |
295 | 299 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
69 | 85 | | |
70 | 86 | | |
71 | 87 | | |
| |||
0 commit comments