Closed
Description
Describe the feature you'd like:
Add a built-in method to query only accessible elements
Suggested implementation:
getByRole('listitem', { accessible: true /* default would be breaking */ })
accessible
checks for:
:not([aria-hidden="true"])
and no ancestor matches[aria-hidden="true"]
- not hidden visibility
Confused it with focusability
Better: It implements https://www.w3.org/TR/wai-aria-1.2/#tree_exclusion
Describe alternatives you've considered:
Implement custom query
Teachability, Documentation, Adoption, Migration Strategy:
Since byRole
is mainly concerned about a11y it should also consider if the node in question is even accessible.
I would make this option configurable for low level tests. These elements are still displayed in the a11y pane in the chrome dev tools and are part of the a11y tree as far as I know. AT (only tested nvda+chrome, expect every AT to match that behavior) does not consider those e.g.
Strawman
<nav aria-label="breadcrumbs">
<ol>
<li><a /></li>
<li aria-hidden="true">/</li>
<li><a /></li>
</ol>
</nav>
will be announced as a list with 2 items while the a11y tree will include 3 elements with the listitem
role.