Commit c18c0fa
authored
Ignore alt check for aria-hidden images (#1851)
* Ignore alt check for aria-hidden images
Treat <img> elements with aria-hidden="true" as exempt from the alt attribute requirement. Update rule implementation (src + built dist) to detect aria-hidden (case-insensitive) and skip the warning, add unit tests for aria-hidden="true" and "TRUE", and update the rule documentation with the new behavior and example.
* Handle trimmed aria-hidden for <img> alt rule
Refine alt-require rule to trim and normalize the aria-hidden attribute when deciding whether an <img> needs an alt. The check now inlines mapAttrs['aria-hidden']?.trim().toLowerCase() !== 'true' (removing the previous isAriaHidden variable) so values with surrounding whitespace are treated correctly. Changes applied to both src (TS) and compiled dist (JS) files.
* Test aria-hidden behavior in alt rule
Add tests to alt-require.spec.js to verify aria-hidden handling: an <img> with aria-hidden=" true " (with surrounding spaces) should not trigger an alt error, while an <img> with aria-hidden="false" should produce a warning (checks include rule id, line, column and type).1 parent 4b74a34 commit c18c0fa
4 files changed
Lines changed: 40 additions & 4 deletions
File tree
- dist/core/rules
- src/core/rules
- test/rules
- website/src/content/docs/rules
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
21 | 49 | | |
22 | 50 | | |
23 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
0 commit comments