|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.4 KB
|
| Line | |
|---|
| 1 | # jsx-a11y/no-redundant-roles
|
|---|
| 2 |
|
|---|
| 3 | 💼 This rule is enabled in the following configs: ☑️ `recommended`, 🔒 `strict`.
|
|---|
| 4 |
|
|---|
| 5 | <!-- end auto-generated rule header -->
|
|---|
| 6 |
|
|---|
| 7 | Some HTML elements have native semantics that are implemented by the browser. This includes default/implicit ARIA roles. Setting an ARIA role that matches its default/implicit role is redundant since it is already set by the browser.
|
|---|
| 8 |
|
|---|
| 9 | ## Rule options
|
|---|
| 10 |
|
|---|
| 11 | The default options for this rule allow an implicit role of `navigation` to be applied to a `nav` element as is [advised by w3](https://www.w3.org/WAI/GL/wiki/Using_HTML5_nav_element#Example:The_.3Cnav.3E_element). The options are provided as an object keyed by HTML element name; the value is an array of implicit ARIA roles that are allowed on the specified element.
|
|---|
| 12 |
|
|---|
| 13 | ```js
|
|---|
| 14 | {
|
|---|
| 15 | 'jsx-a11y/no-redundant-roles': [
|
|---|
| 16 | 'error',
|
|---|
| 17 | {
|
|---|
| 18 | nav: ['navigation'],
|
|---|
| 19 | },
|
|---|
| 20 | ],
|
|---|
| 21 | }
|
|---|
| 22 | ```
|
|---|
| 23 |
|
|---|
| 24 | ### Succeed
|
|---|
| 25 |
|
|---|
| 26 | ```jsx
|
|---|
| 27 | <div />
|
|---|
| 28 | <button role="presentation" />
|
|---|
| 29 | <MyComponent role="main" />
|
|---|
| 30 | ```
|
|---|
| 31 |
|
|---|
| 32 | ### Fail
|
|---|
| 33 |
|
|---|
| 34 | ```jsx
|
|---|
| 35 | <button role="button" />
|
|---|
| 36 | <img role="img" src="foo.jpg" />
|
|---|
| 37 | ```
|
|---|
| 38 |
|
|---|
| 39 | ## Accessibility guidelines
|
|---|
| 40 |
|
|---|
| 41 | General best practice (reference resources)
|
|---|
| 42 |
|
|---|
| 43 | ### Resources
|
|---|
| 44 |
|
|---|
| 45 | - [ARIA Spec, ARIA Adds Nothing to Default Semantics of Most HTML Elements](https://www.w3.org/TR/using-aria/#aria-does-nothing)
|
|---|
| 46 | - [Identifying SVG as an image](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#identifying_svg_as_an_image)
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.