web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.4 KiB

  1. # aria-role
  2. Elements with ARIA roles must use a valid, non-abstract ARIA role. A reference to role definitions can be found at [WAI-ARIA](https://www.w3.org/TR/wai-aria/#role_definitions) site.
  3. ## Rule details
  4. This rule takes one optional object argument of type object:
  5. ```json
  6. {
  7. "rules": {
  8. "jsx-a11y/aria-role": [ 2, {
  9. "ignoreNonDOM": true
  10. }],
  11. }
  12. }
  13. ```
  14. For the `ignoreNonDOM` option, this determines if developer created components are checked.
  15. ### Succeed
  16. ```jsx
  17. <div role="button"></div> <!-- Good: "button" is a valid ARIA role -->
  18. <div role={role}></div> <!-- Good: role is a variable & cannot be determined until runtime. -->
  19. <div></div> <!-- Good: No ARIA role -->
  20. <Foo role={role}></Foo> <!-- Good: ignoreNonDOM is set to true -->
  21. ```
  22. ### Fail
  23. ```jsx
  24. <div role="datepicker"></div> <!-- Bad: "datepicker" is not an ARIA role -->
  25. <div role="range"></div> <!-- Bad: "range" is an _abstract_ ARIA role -->
  26. <div role=""></div> <!-- Bad: An empty ARIA role is not allowed -->
  27. <Foo role={role}></Foo> <!-- Bad: ignoreNonDOM is set to false or not set -->
  28. ```
  29. ## Accessibility guidelines
  30. - [WCAG 4.1.2](https://www.w3.org/WAI/WCAG21/Understanding/name-role-value)
  31. ### Resources
  32. - [Chrome Audit Rules, AX_ARIA_01](https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_aria_01)
  33. - [DPUB-ARIA roles](https://www.w3.org/TR/dpub-aria-1.0/)