Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

react a11y role has required props Rule

t-ligu edited this page Sep 20, 2016 · 1 revision

react-a11y-role-has-required-aria-props

Elements with aria roles must have all required attributes according to the role.

References

Rule options

This rule takes no arguments.

Examples

Bad

// The <div> element has no required attribute aria-checked for checkbox role.
<div role='checkbox' />

Good

// The <div> element has required attribute aria-checked for checkbox role.
<div role='checkbox' aria-checked='false' />

Note

When an element has explicit and implicit roles at the same time, the explicit role will be used first. For example:

Bad

// <input> element explicit role is checkbox, it requires aria-checked attribute.
<input role='checkbox' type='button' />

Good

// <input> element implicit role is checkbox, it has required aria-checked attribute.
<input role='checkbox' aria-checked='true' />