mirror of https://github.com/sveltejs/svelte
feat: a11y warning for `<button>` / `<a>` without aria-label and content (#13130)
* Introduce button a11y warnings * Log changeset * Don't check for label if aria-hidden * State based flag to avoid multiple warnings firing * Update existing validators to include aria labels * false positives are okay, false negatives aren't * prefer text over aria-label in tests * remove unnecessary aria-labels * tweak message * update test * fix * simplify * various * DRY out * Apply suggestions from code review --------- Co-authored-by: Rich Harris <rich.harris@vercel.com> Co-authored-by: Rich Harris <hello@rich-harris.dev>pull/13294/head
parent
758fb2aa0f
commit
c229e0f80b
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
feat: Add accessibility warnings for buttons and anchors without explicit labels and content
|
@ -0,0 +1,11 @@
|
|||||||
|
<button></button>
|
||||||
|
<a href="/#"><b></b></a>
|
||||||
|
|
||||||
|
<button aria-label="Valid empty button"></button>
|
||||||
|
<a href="/#" aria-label="Valid empty link"></a>
|
||||||
|
|
||||||
|
<button aria-hidden='true'></button>
|
||||||
|
<a href="/#" aria-hidden='true'><b></b></a>
|
||||||
|
|
||||||
|
<button>Click me</button>
|
||||||
|
<a href="/#">Link text</a>
|
@ -0,0 +1,26 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"code": "a11y_consider_explicit_label",
|
||||||
|
"message": "Buttons and links should either contain text or have an `aria-label` or `aria-labelledby` attribute",
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 17
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "a11y_consider_explicit_label",
|
||||||
|
"message": "Buttons and links should either contain text or have an `aria-label` or `aria-labelledby` attribute",
|
||||||
|
"start": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 24
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
Loading…
Reference in new issue