Skip to content

fix: define role="application" as an interactive ARIA role #8975

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: svelte-4
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/calm-walls-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

define `role="application"` as an interactive ARIA role
3 changes: 2 additions & 1 deletion packages/svelte/src/compiler/compile/utils/a11y.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const non_interactive_roles = new Set(
// focusable tabpanel elements are recommended if any panels in a set contain content where the first element in the panel is not focusable.
// 'generic' is meant to have no semantic meaning.
// 'cell' is treated as CellRole by the AXObject which is interactive, so we treat 'cell' it as interactive as well.
!['toolbar', 'tabpanel', 'generic', 'cell'].includes(name) &&
// 'application' describes interactive elements that do not follow a standard pattern supported by a widget role
!['toolbar', 'tabpanel', 'generic', 'cell', 'application'].includes(name) &&
!role.superClass.some((classes) => classes.includes('widget'))
);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@
<div role="textbox" />
<div role="treeitem" aria-selected={true} />
<summary role="listitem" />
<div role="application" />

<!-- HTML elements attributed with a non-interactive role -->
<div role="alert" />
<div role="alertdialog" />
<div role="application" />
<div role="article" />
<div role="banner" />
<div role="cell" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<button on:click={() => {}} />
<h1 contenteditable="true" on:keydown={() => {}}>Heading</h1>
<h1>Heading</h1>
<div role="application" on:keydown={() => {}} tabindex="-1"/>

<!-- INVALID -->
<div role="listitem" on:mousedown={() => {}} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,60 @@
"code": "a11y-no-noninteractive-element-interactions",
"end": {
"column": 47,
"line": 10
"line": 11
},
"message": "A11y: Non-interactive element <div> should not be assigned mouse or keyboard event listeners.",
"start": {
"column": 0,
"line": 10
"line": 11
}
},
{
"code": "a11y-no-noninteractive-element-interactions",
"end": {
"column": 58,
"line": 11
"line": 12
},
"message": "A11y: Non-interactive element <h1> should not be assigned mouse or keyboard event listeners.",
"start": {
"column": 0,
"line": 11
"line": 12
}
},
{
"code": "a11y-no-noninteractive-element-interactions",
"end": {
"column": 50,
"line": 12
"line": 13
},
"message": "A11y: Non-interactive element <h1> should not be assigned mouse or keyboard event listeners.",
"start": {
"column": 0,
"line": 12
"line": 13
}
},
{
"code": "a11y-no-noninteractive-element-interactions",
"end": {
"column": 28,
"line": 13
"line": 14
},
"message": "A11y: Non-interactive element <p> should not be assigned mouse or keyboard event listeners.",
"start": {
"column": 0,
"line": 13
"line": 14
}
},
{
"code": "a11y-no-noninteractive-element-interactions",
"end": {
"column": 46,
"line": 14
"line": 15
},
"message": "A11y: Non-interactive element <div> should not be assigned mouse or keyboard event listeners.",
"start": {
"column": 0,
"line": 14
"line": 15
}
}
]