Dostępność
a11y/aria-ref-exists
Ids named in aria-labelledby, aria-describedby and aria-errormessage exist in the page and are unique.
poważnastatyczneWCAG 1.3.1, 4.1.2 · Afe-a11y-aria
Dlaczego
A reference to a missing id is dropped without a warning, so the hint, the error or the label is never read. When two elements share the id, the first one wins and the user may hear the wrong text.
Poprawka
Correct the id or the reference, and make ids unique per page. In components, generate ids (useId() in React and Vue 3.5, $props.id() in Svelte 5) and pass them down instead of hard-coding them.
Przykłady
<!-- bad -->
<input id="email" aria-describedby="email-hint"><p id="emailhint">…</p>
<!-- good -->
<input id="email" aria-describedby="email-hint"><p id="email-hint">…</p>Źródła
Fakty
- Identyfikator
a11y/aria-ref-exists- Waga
- poważna
- Sprawdzanie
- statyczne sprawdzane w kodzie źródłowym przez
audit - Dotyczy plików
html- WCAG 2.2
- 1.3.1, 4.1.2, poziom A
- Ten sam problem w
- axe-core
aria-valid-attr-value, axe-coreduplicate-id-aria - 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-ref-exists