fix: ignore popover elements in a11y_consider_explicit_label check (#17367)

* fix: ignore popover elements in a11y_consider_explicit_label check

* chore: add changeset

* Apply suggestions from code review

* Apply suggestions from code review

* fix

---------

Co-authored-by: Rich Harris <hello@rich-harris.dev>
Co-authored-by: Rich Harris <rich.harris@vercel.com>
pull/17576/head
Razin Shafayet 8 months ago committed by GitHub
parent 08448c501b
commit 3256a75b54
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: disregard `popover` elements when determining whether an element has content

@ -824,6 +824,10 @@ function has_content(element) {
}
if (node.type === 'RegularElement' || node.type === 'SvelteElement') {
if (node.attributes.some((a) => a.type === 'Attribute' && a.name === 'popover')) {
continue;
}
if (
node.name === 'img' &&
node.attributes.some((node) => node.type === 'Attribute' && node.name === 'alt')

@ -0,0 +1,3 @@
<button interestfor="my-hint">
<div id="my-hint" popover="hint">hello</div>
</button>

@ -0,0 +1,14 @@
[
{
"code": "a11y_consider_explicit_label",
"message": "Buttons and links should either contain text or have an `aria-label`, `aria-labelledby` or `title` attribute",
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 9
}
}
]
Loading…
Cancel
Save