You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/rules/anchor-ambiguous-text.md
+9-1
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,13 @@ The `words` option allows users to modify the strings that can be checked for in
22
22
constDEFAULT_AMBIGUOUS_WORDS= ['click here', 'here', 'link', 'a link', 'learn more'];
23
23
```
24
24
25
-
If an element has the `aria-label` property, its value is used instead of the inner text. Note that the rule still disallows ambiguous `aria-label`s. This rule also skips over elements with `aria-hidden="true"`.
25
+
The logic to calculate the inner text of an anchor is as follows:
26
+
27
+
- if an element has the `aria-label` property, its value is used instead of the inner text
28
+
- if an element has `aria-hidden="true`, it is skipped over
29
+
- if an element is `<img />` or configured to be interpreted like one, its `alt` value is used as its inner text
30
+
31
+
Note that this rule still disallows ambiguous `aria-label` or `alt` values.
26
32
27
33
Note that this rule is case-insensitive and trims whitespace. It only looks for **exact matches**.
28
34
@@ -46,6 +52,8 @@ Note that this rule is case-insensitive and trims whitespace. It only looks for
46
52
<a><i></i>a link</a>
47
53
<a><span aria-hidden="true">more text</span>learn more</a>// skips over elements with aria-hidden=true
48
54
<a aria-label="click here">something</a>// the aria-label here is inaccessible
55
+
<a><img alt="click here"/></a>// the alt tag is still ambiguous
56
+
<a alt="tutorial on using eslint-plugin-jsx-a11y">click here</a>// the alt tag is only parsed on img
0 commit comments