From 75aa6ba38d58c83ff012bed77c39edb814e43bc6 Mon Sep 17 00:00:00 2001 From: G Date: Fri, 25 Sep 2026 04:44:00 +0200 Subject: [PATCH] fix: don't warn about redundant `link` role on `` without `href` (#18872) Since #11737, `` without an `href` no longer triggers `a11y_no_redundant_roles`, but `` without an `href` still does. Per [ARIA in HTML](https://www.w3.org/TR/html-aria/#el-area-no-href), an `` without `href` has the implicit role `generic` and `link` is one of its allowed roles, so the role isn't redundant. This applies the existing `` exception to `` and adds test cases for `` with and without `href`. Closes #9261. The `` example in that issue was already fixed by #11737, but the issue was left open. ### Before submitting the PR, please make sure you do the following - [x] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs - [x] Prefix your PR title with `feat:`, `fix:`, `chore:`, or `docs:`. - [x] This message body should clearly illustrate what problems it solves. - [x] Ideally, include a test that fails without this PR but passes with it. - [x] If this PR changes code within `packages/svelte/src`, add a changeset (`npx changeset`). ### Tests and linting - [x] Run the tests with `pnpm test` and lint the project with `pnpm lint` --- .changeset/quiet-areas-link.md | 5 +++++ .../phases/2-analyze/visitors/shared/a11y/index.js | 4 ++-- .../samples/a11y-no-redundant-roles/input.svelte | 5 +++++ .../samples/a11y-no-redundant-roles/warnings.json | 12 ++++++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 .changeset/quiet-areas-link.md diff --git a/.changeset/quiet-areas-link.md b/.changeset/quiet-areas-link.md new file mode 100644 index 0000000000..af4e31f3cb --- /dev/null +++ b/.changeset/quiet-areas-link.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: don't warn about a redundant `link` role on `` elements without an `href` 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 f06a41d088..c38b03bf69 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 @@ -173,8 +173,8 @@ export function check_element(node, context) { current_role === get_implicit_role(node.name, attribute_map) && //