diff --git a/.changeset/silly-ducks-mix.md b/.changeset/silly-ducks-mix.md
new file mode 100644
index 0000000000..411f834518
--- /dev/null
+++ b/.changeset/silly-ducks-mix.md
@@ -0,0 +1,5 @@
+---
+"svelte": patch
+---
+
+fix: don't warn on link without href if aria-disabled
diff --git a/packages/svelte/src/compiler/phases/2-analyze/a11y.js b/packages/svelte/src/compiler/phases/2-analyze/a11y.js
index a45c3c1f97..ff9ec636ab 100644
--- a/packages/svelte/src/compiler/phases/2-analyze/a11y.js
+++ b/packages/svelte/src/compiler/phases/2-analyze/a11y.js
@@ -793,7 +793,9 @@ function check_element(node, state) {
if (
current_role === get_implicit_role(node.name, attribute_map) &&
//
is ok because CSS list-style:none removes the semantics and this is a way to bring them back
- !['ul', 'ol', 'li'].includes(node.name)
+ !['ul', 'ol', 'li'].includes(node.name) &&
+ // is ok because without href the a tag doesn't have a role of link
+ !(node.name === 'a' && !attribute_map.has('href'))
) {
w.a11y_no_redundant_roles(attribute, current_role);
}
@@ -1023,7 +1025,8 @@ function check_element(node, state) {
} else if (!has_spread) {
const id_attribute = get_static_value(attribute_map.get('id'));
const name_attribute = get_static_value(attribute_map.get('name'));
- if (!id_attribute && !name_attribute) {
+ const aria_disabled_attribute = get_static_value(attribute_map.get('aria-disabled'));
+ if (!id_attribute && !name_attribute && aria_disabled_attribute !== 'true') {
warn_missing_attribute(node, ['href']);
}
}
diff --git a/packages/svelte/tests/validator/samples/a11y-missing-attribute-href-aria-disabled/input.svelte b/packages/svelte/tests/validator/samples/a11y-missing-attribute-href-aria-disabled/input.svelte
new file mode 100644
index 0000000000..cec44a6577
--- /dev/null
+++ b/packages/svelte/tests/validator/samples/a11y-missing-attribute-href-aria-disabled/input.svelte
@@ -0,0 +1 @@
+Back
\ No newline at end of file
diff --git a/packages/svelte/tests/validator/samples/a11y-missing-attribute-href-aria-disabled/warnings.json b/packages/svelte/tests/validator/samples/a11y-missing-attribute-href-aria-disabled/warnings.json
new file mode 100644
index 0000000000..fe51488c70
--- /dev/null
+++ b/packages/svelte/tests/validator/samples/a11y-missing-attribute-href-aria-disabled/warnings.json
@@ -0,0 +1 @@
+[]