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
html angular vue svelte astro jsx
WCAG 2.2
4.1.2, poziom A
Ten sam problem w
axe-core aria-roles, axe-core aria-valid-attr, Lighthouse aria-roles, Lighthouse aria-valid-attr
Uczy jej skill
fe-a11y-aria ARIA, names and live regions
Od wersji
0.1.0

Plik reguły na GitHubie

Przeczytaj w terminalu

npx github:dawidolko/frontend-skills explain a11y/aria-valid