-
Notifications
You must be signed in to change notification settings - Fork 795
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(name-rules): ignore when explicit roles don't require a name (#2629)
* fix(name-rules): ignore when explicit roles don't require a name * docs(standards): fix typo in ariaRole prop
- Loading branch information
1 parent
e77992e
commit 52fb138
Showing
20 changed files
with
201 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { isFocusable } from '../commons/dom'; | ||
import { getExplicitRole } from '../commons/aria'; | ||
import ariaRoles from '../standards/aria-roles'; | ||
|
||
/** | ||
* Filter out elements with an explicit role that does not require an accessible name and is not focusable | ||
*/ | ||
function noExplicitNameRequired(node, virtualNode) { | ||
const role = getExplicitRole(virtualNode); | ||
if (!role || ['none', 'presentation'].includes(role)) { | ||
return true; | ||
} | ||
|
||
const { accessibleNameRequired } = ariaRoles[role] || {}; | ||
if (accessibleNameRequired || isFocusable(virtualNode)) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
export default noExplicitNameRequired; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.