This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 198
react a11y role supports aria props Rule
t-ligu edited this page Sep 20, 2016
·
1 revision
Enforce that elements with explicit or implicit roles defined contain only aria-*
properties supported by that role
.
Many aria attributes (states and properties) can only be used on elements with particular roles. Some elements have implicit roles, such as <a href='hrefValue' />
, which will be resolved to role='link'
. A reference for the implicit roles can be found at Default Implicit ARIA Semantics.
This rule takes no arguments.
// The explicit checkbox role does not support the aria-checked attribute.
<div role='button' aria-checked='true' />
// The implicit link role does not support the aria-checked attribute.
<a href='hrefValue' aria-checked='true' aria-hidden />
// The explicit checkbox role does support the aria-checked attribute.
<div role='checkbox' aria-checked='true' />
// The implicit link role does support the aria-label and aria-hidden attributes.
<a href='hrefValue' aria-label='labelID' aria-hidden />
When an element has explicit and implicit roles at the same time, the explicit role will be used first. For example:
// The <input> element explicit role is button, it does not support aria-checked attribute.
<input role='button' type='checkbox' aria-checked='true' />
// The <input> element explicit role is checkbox, it supports aria-checked attribute.
<input role='checkbox' type='button' aria-checked='true' />