fix: silence a11y warning for inert elements (#16339)

* fix: silence a11y warning for inert elements

* changeset

* handle `inert=""`

* oops

---------

Co-authored-by: Rich Harris <rich.harris@vercel.com>
pull/16364/head
Ahmad S. 2 months ago committed by GitHub
parent 0672e48223
commit 63b5ebf36e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: silence a11y warning for inert elements

@ -387,7 +387,10 @@ export function check_element(node, context) {
switch (node.name) { switch (node.name) {
case 'a': case 'a':
case 'button': { case 'button': {
const is_hidden = get_static_value(attribute_map.get('aria-hidden')) === 'true'; const is_hidden =
get_static_value(attribute_map.get('aria-hidden')) === 'true' ||
get_static_value(attribute_map.get('inert')) !== null;
if (!has_spread && !is_hidden && !is_labelled && !has_content(node)) { if (!has_spread && !is_hidden && !is_labelled && !has_content(node)) {
w.a11y_consider_explicit_label(node); w.a11y_consider_explicit_label(node);
} }

@ -5,6 +5,7 @@
<a href="/#" aria-label="Valid empty link"></a> <a href="/#" aria-label="Valid empty link"></a>
<button aria-hidden='true'></button> <button aria-hidden='true'></button>
<button inert></button>
<a href="/#" aria-hidden='true'><b></b></a> <a href="/#" aria-hidden='true'><b></b></a>
<button>Click me</button> <button>Click me</button>

Loading…
Cancel
Save