Skip to content

Commit

Permalink
feat: bail on role="presentation" elements
Browse files Browse the repository at this point in the history
chore: convert selector constant to array of strings
  • Loading branch information
mxmason committed Jan 3, 2023
1 parent a688354 commit 644d46e
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/a11y-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,19 +221,20 @@ function moveFocusToDialog(node: HTMLElement) {
// Elements with these ARIA roles make their children
// `presentational`, which nullifies their semantics.
// @see: https://www.w3.org/TR/wai-aria/
const PRESENTATIONAL_CHILDREN_SELECTOR = `
a[href],
button,
img,
summary,
[role="button"],
[role="image"],
[role="link"],
[role="math"],
[role="progressbar"],
[role="scrollbar"],
[role="slider"]
`
const PRESENTATIONAL_CHILDREN_SELECTOR = [
'a[href]',
'button',
'img',
'summary',
'[role="button"]',
'[role="image"]',
'[role="link"]',
'[role="math"]',
'[role="presentation"]',
'[role="progressbar"]',
'[role="scrollbar"]',
'[role="slider"]',
].join(',')

/**
* Get focusable children by recursively traversing the subtree of `node`.
Expand Down

0 comments on commit 644d46e

Please sign in to comment.