jsx_a11y/role-supports-aria-props 正確性
功能
強制具有明確或隱含角色定義的元素,僅包含該role
支援的aria-*
屬性。許多 ARIA 屬性 (狀態和屬性) 只能用於具有特定角色的元素。某些元素具有隱含的角色,例如 <a href="#" />
,將解析為 role="link"
。
範例
此規則的 不正確 程式碼範例
jsx
<ul role="radiogroup" "aria-labelledby"="foo">
<li aria-required tabIndex="-1" role="radio" aria-checked="false">Rainbow Trout</li>
<li aria-required tabIndex="-1" role="radio" aria-checked="false">Brook Trout</li>
<li aria-required tabIndex="0" role="radio" aria-checked="true">Lake Trout</li>
</ul>
此規則的 正確 程式碼範例
jsx
<ul role="radiogroup" aria-required "aria-labelledby"="foo">
<li tabIndex="-1" role="radio" aria-checked="false">Rainbow Trout</li>
<li tabIndex="-1" role="radio" aria-checked="false">Brook Trout</li>
<li tabIndex="0" role="radio" aria-checked="true">Lake Trout</li>
</ul>