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.

67 lines
2.6 KiB

  1. # no-interactive-element-to-noninteractive-role
  2. Interactive HTML elements indicate _controls_ in the user interface. Interactive elements include `<a href>`, `<button>`, `<input>`, `<select>`, `<textarea>`.
  3. Non-interactive HTML elements and non-interactive ARIA roles indicate _content_ and _containers_ in the user interface. Non-interactive elements include `<main>`, `<area>`, `<h1>` (,`<h2>`, etc), `<img>`, `<li>`, `<ul>` and `<ol>`.
  4. [WAI-ARIA roles](https://www.w3.org/TR/wai-aria-1.1/#usage_intro) should not be used to convert an interactive element to a non-interactive element. Non-interactive ARIA roles include `article`, `banner`, `complementary`, `img`, `listitem`, `main`, `region` and `tooltip`.
  5. ## How do I resolve this error?
  6. ### Case: The element should be a container, like an article
  7. Wrap your interactive element in a `<div>` with the desired role.
  8. ```jsx
  9. <div role="article">
  10. <button>Save</button>
  11. </div>
  12. ```
  13. ### Case: The element should be content, like an image
  14. Put the content inside your interactive element.
  15. ```jsx
  16. <div
  17. role="button"
  18. onClick={() => {}}
  19. onKeyPress={() => {}}
  20. tabIndex="0">
  21. <div role="img" aria-label="Save" />
  22. </div>
  23. ```
  24. ## Rule details
  25. The recommended options for this rule allow the `tr` element to be given a role of `presentation` (or its semantic equivalent `none`). Under normal circumstances, an element with an interactive role should not be semantically neutralized with `presentation` (or `none`).
  26. Options are provided as an object keyed by HTML element name; the value is an array of interactive roles that are allowed on the specified element.
  27. ```js
  28. {
  29. 'no-interactive-element-to-noninteractive-role': [
  30. 'error',
  31. {
  32. tr: ['none', 'presentation'],
  33. },
  34. ]
  35. }
  36. ```
  37. Under the recommended options, the following code is valid. It would be invalid under the strict rules.
  38. ```jsx
  39. <tr role="presentation" />
  40. ```
  41. ## Accessibility guidelines
  42. - [WCAG 4.1.2](https://www.w3.org/WAI/WCAG21/Understanding/name-role-value)
  43. ### Resources
  44. - [ARIA Spec, States and Properties](https://www.w3.org/TR/wai-aria/#states_and_properties)
  45. - [Chrome Audit Rules, AX_ARIA_04](https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_aria_04)
  46. - [WAI-ARIA roles](https://www.w3.org/TR/wai-aria-1.1/#usage_intro)
  47. - [WAI-ARIA Authoring Practices Guide - Design Patterns and Widgets](https://www.w3.org/TR/wai-aria-practices-1.1/#aria_ex)
  48. - [Fundamental Keyboard Navigation Conventions](https://www.w3.org/TR/wai-aria-practices-1.1/#kbd_generalnav)
  49. - [Mozilla Developer Network - ARIA Techniques](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_button_role#Keyboard_and_focus)