Skip to content

Commit 01f386f

Browse files
committed
fix: silence a11y warning for inert elements
1 parent 443e76e commit 01f386f

File tree

2 files changed

+4
-1
lines changed
  • packages/svelte
    • src/compiler/phases/2-analyze/visitors/shared
    • tests/validator/samples/a11y-consider-explicit-label

2 files changed

+4
-1
lines changed

packages/svelte/src/compiler/phases/2-analyze/visitors/shared/a11y.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,9 @@ export function check_element(node, context) {
999999
const is_labelled = attribute_map.has('aria-label') || attribute_map.has('aria-labelledby');
10001000

10011001
if (node.name === 'a' || node.name === 'button') {
1002-
const is_hidden = get_static_value(attribute_map.get('aria-hidden')) === 'true';
1002+
const is_hidden =
1003+
get_static_value(attribute_map.get('aria-hidden')) === 'true' ||
1004+
get_static_value(attribute_map.get('inert'));
10031005

10041006
if (!has_spread && !is_hidden && !is_labelled && !has_content(node)) {
10051007
w.a11y_consider_explicit_label(node);

packages/svelte/tests/validator/samples/a11y-consider-explicit-label/input.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<a href="/#" aria-label="Valid empty link"></a>
66

77
<button aria-hidden='true'></button>
8+
<button inert></button>
89
<a href="/#" aria-hidden='true'><b></b></a>
910

1011
<button>Click me</button>

0 commit comments

Comments
 (0)