From 055e28c915eba1fd1611cfeac3fd80a1cafca283 Mon Sep 17 00:00:00 2001 From: razinshafayet Date: Tue, 16 Dec 2025 11:36:45 +0600 Subject: [PATCH 1/2] fix: ignore popover elements in a11y_consider_explicit_label check --- .../2-analyze/visitors/shared/a11y/index.js | 6 ++++++ .../samples/a11y-popover-label/input.svelte | 17 +++++++++++++++++ .../samples/a11y-popover-label/warnings.json | 8 ++++++++ 3 files changed, 31 insertions(+) create mode 100644 packages/svelte/tests/validator/samples/a11y-popover-label/input.svelte create mode 100644 packages/svelte/tests/validator/samples/a11y-popover-label/warnings.json diff --git a/packages/svelte/src/compiler/phases/2-analyze/visitors/shared/a11y/index.js b/packages/svelte/src/compiler/phases/2-analyze/visitors/shared/a11y/index.js index 717ee4bf50d9..301a5b19eb81 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/visitors/shared/a11y/index.js +++ b/packages/svelte/src/compiler/phases/2-analyze/visitors/shared/a11y/index.js @@ -824,6 +824,12 @@ function has_content(element) { } if (node.type === 'RegularElement' || node.type === 'SvelteElement') { + // FIX START: Ignore elements with the popover attribute + if (node.attributes.some((a) => a.type === 'Attribute' && a.name === 'popover')) { + continue; + } + // FIX END + if ( node.name === 'img' && node.attributes.some((node) => node.type === 'Attribute' && node.name === 'alt') diff --git a/packages/svelte/tests/validator/samples/a11y-popover-label/input.svelte b/packages/svelte/tests/validator/samples/a11y-popover-label/input.svelte new file mode 100644 index 000000000000..98548e737d1b --- /dev/null +++ b/packages/svelte/tests/validator/samples/a11y-popover-label/input.svelte @@ -0,0 +1,17 @@ + + + \ No newline at end of file diff --git a/packages/svelte/tests/validator/samples/a11y-popover-label/warnings.json b/packages/svelte/tests/validator/samples/a11y-popover-label/warnings.json new file mode 100644 index 000000000000..b760163647db --- /dev/null +++ b/packages/svelte/tests/validator/samples/a11y-popover-label/warnings.json @@ -0,0 +1,8 @@ +[ + { + "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": 6, "column": 11 } + } +] From df72d30b2c758a91aa73cb0889e13f6aa1740516 Mon Sep 17 00:00:00 2001 From: razinshafayet Date: Tue, 16 Dec 2025 11:41:45 +0600 Subject: [PATCH 2/2] chore: add changeset --- .changeset/shaggy-phones-laugh.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/shaggy-phones-laugh.md diff --git a/.changeset/shaggy-phones-laugh.md b/.changeset/shaggy-phones-laugh.md new file mode 100644 index 000000000000..dde4469c6da3 --- /dev/null +++ b/.changeset/shaggy-phones-laugh.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +Fix false negative for a11y_consider_explicit_label with popover elements