Dostępność
a11y/aria-valid
Every role value is a real WAI-ARIA role and every aria-* attribute name exists (aria-labelledby, not aria-labeledby).
poważnastatyczneWCAG 4.1.2 · Afe-a11y-aria
Dlaczego
Browsers ignore an unknown role or attribute without any error. The widget then has no role, no name or no state for assistive technology, while the code looks finished.
Poprawka
Use the role names of WAI-ARIA 1.2 (tablist, not tabs) and the exact attribute names (aria-labelledby, aria-describedby). Better still, use the native element that carries the role. Lint JSX with eslint-plugin-jsx-a11y to catch these while typing.
Przykłady
<!-- bad -->
<div role="tabs"><button aria-labeledby="t1">One</button></div>
<!-- good -->
<div role="tablist"><button role="tab" aria-labelledby="t1">One</button></div>Źródła
Fakty
- Identyfikator
a11y/aria-valid- Waga
- poważna
- Sprawdzanie
- statyczne sprawdzane w kodzie źródłowym przez
audit - Dotyczy plików
htmlangularvuesvelteastrojsx- WCAG 2.2
- 4.1.2, poziom A
- Ten sam problem w
- axe-core
aria-roles, axe-corearia-valid-attr, Lighthousearia-roles, Lighthousearia-valid-attr - Uczy jej skill
fe-a11y-ariaARIA, names and live regions- Od wersji
- 0.1.0
Przeczytaj w terminalu
npx github:dawidolko/frontend-skills explain a11y/aria-valid