From 1cfed0bf2980567787edd1d813f6ce50eaf3f033 Mon Sep 17 00:00:00 2001
From: Simon H <5968653+dummdidumm@users.noreply.github.com>
Date: Wed, 28 Jun 2023 12:29:44 +0200
Subject: [PATCH] fix: relax a11y "no redundant role" rule for li, ul, ol
(#8867)
fixes #8854
---
.changeset/pretty-tools-whisper.md | 5 +++
.../src/compiler/compile/nodes/Element.js | 6 +++-
.../a11y-no-redundant-roles/input.svelte | 12 +++----
.../a11y-no-redundant-roles/warnings.json | 36 -------------------
4 files changed, 16 insertions(+), 43 deletions(-)
create mode 100644 .changeset/pretty-tools-whisper.md
diff --git a/.changeset/pretty-tools-whisper.md b/.changeset/pretty-tools-whisper.md
new file mode 100644
index 0000000000..8af633242f
--- /dev/null
+++ b/.changeset/pretty-tools-whisper.md
@@ -0,0 +1,5 @@
+---
+'svelte': patch
+---
+
+fix: relax a11y "no redundant role" rule for li, ul, ol
diff --git a/packages/svelte/src/compiler/compile/nodes/Element.js b/packages/svelte/src/compiler/compile/nodes/Element.js
index 3b18ce0e94..ecefb0c34e 100644
--- a/packages/svelte/src/compiler/compile/nodes/Element.js
+++ b/packages/svelte/src/compiler/compile/nodes/Element.js
@@ -694,7 +694,11 @@ export default class Element extends Node {
);
}
// no-redundant-roles
- if (current_role === get_implicit_role(this.name, attribute_map)) {
+ if (
+ current_role === get_implicit_role(this.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(this.name)
+ ) {
component.warn(
attribute,
compiler_warnings.a11y_no_redundant_roles(current_role)
diff --git a/packages/svelte/test/validator/samples/a11y-no-redundant-roles/input.svelte b/packages/svelte/test/validator/samples/a11y-no-redundant-roles/input.svelte
index 537d5c0fd3..e5c987d691 100644
--- a/packages/svelte/test/validator/samples/a11y-no-redundant-roles/input.svelte
+++ b/packages/svelte/test/validator/samples/a11y-no-redundant-roles/input.svelte
@@ -19,12 +19,12 @@