webcomponents / webcomponents/polyfills

[ShadyDOM] HTMLElement ids don't get scoped

Open
#47 4 comments 1 reaction 0 assignees View on GitHub
Package: shadydom Severity: Medium Type: Feature wontfix
Dominant language
HTML
Stars
1.2k
Forks
168
PR merge metrics
No merged PRs in 30d

Description

Unless I'm doing something wrong, it appears as if element ids aren't getting properly scoped inside their shadow root. If I have a custom input component with a label and input, the `htmlFor` and `id` need to be dynamically set (or have some unique ID appended to them) to keep the form accessible, the markup valid and maintain general HTML rules (clicking an label focuses the input, tooltips associated with `aria-describedby` etc.).

I had assumed that there would be some modification to the ID attribute to keep the HTML valid. Presumably, we could then patch `ShadowRoot.prototype.getElementById` to use some pre-configured `Map` object instead of the normal `getElementById`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.