Skip to content

Commit 96c1a10

Browse files
authored
fix: silence autofocus a11y warning inside <dialog> (#16341)
1 parent e802d3b commit 96c1a10

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

.changeset/cuddly-humans-end.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: silence autofocus a11y warning inside `<dialog>`

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ export function check_element(node, context) {
877877
}
878878

879879
// no-autofocus
880-
if (name === 'autofocus') {
880+
if (name === 'autofocus' && node.name !== 'dialog' && !is_parent(context.path, ['dialog'])) {
881881
w.a11y_autofocus(attribute);
882882
}
883883

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
<div autofocus></div>
1+
<div autofocus></div>
2+
<dialog autofocus>
3+
</dialog>
4+
<dialog>
5+
<input autofocus>
6+
</dialog>

0 commit comments

Comments
 (0)