Web Components
webc/aria-idrefs-same-tree
id references (for, aria-labelledby, aria-describedby, aria-controls) point at an element in the same DOM tree, not across a shadow root.
poważnaręczneWCAG 1.3.1, 4.1.2 · Afe-web-components
Dlaczego
An id is only looked up inside its own tree. <label for="email"> in the page cannot reach <input id="email"> inside a component's shadow root, and aria-describedby="hint" inside the shadow root cannot reach a hint in the page. The relationship looks right in the source and is simply missing for screen readers: the field is announced without a name or a description.
Poprawka
Keep the label and the control in the same tree: render the label inside the component from an attribute or a slot, or make the host form-associated so an outer <label for="host-id"> labels the host (webc/form-associated). For descriptions, pass the text in and render it next to the inner control. Test with a screen reader or the browser's accessibility tree; automated checkers do not reliably follow references across shadow roots. Cross-root references (referenceTarget) are still being specified; do not rely on them yet.
Przykłady
<!-- bad: the label cannot see the input inside the shadow root -->
<label for="email">Email</label>
<acme-input id="email"></acme-input>
<!-- good: the component renders its own label -->
<acme-input label="Email" type="email" autocomplete="email"></acme-input>Źródła
Fakty
- Identyfikator
webc/aria-idrefs-same-tree- Waga
- poważna
- Sprawdzanie
- ręczne ocenia człowiek; raport podaje to jako listę kontrolną
- Dotyczy plików
jsxhtml- WCAG 2.2
- 1.3.1, 4.1.2, poziom A
- Uczy jej skill
fe-web-componentsWeb components and Lit- Od wersji
- 0.1.0
Przeczytaj w terminalu
npx github:dawidolko/frontend-skills explain webc/aria-idrefs-same-tree