webcomponents / webcomponents/polyfills
[scoped-custom-element-registry] The scoped registry doesn't work if the DOM already contains the web component when it is defined.
Open
Focus Area: Standards & Polyfills
Type: Bug
- Dominant language
- HTML
- Stars
- 1.2k
- Forks
- 168
- PR merge metrics
- No merged PRs in 30d
Description
```ts
class Foo extends ScopedElementsMixin(LitElement) {
static get scopedElements() {
return { 'x-bar': Bar };
}
}
```
0. Load the polyfill
1. Have `` in the DOM
2. Call `customElements.define('x-foo', Foo);`
3. `window.customElements.get('x-bar') === Bar`
Step 3 should be `false`, but is `true`.
If I remove `` from the DOM, then step 3 is false.
Also this only seems to happen with a production (rollup) build, not with a dev build :/ (specifically `storybook build` using vite build vs `storybook dev`)
Atm I only have time to report this and not create a reproduction :/
Contributor guide
Assessment
This issue has not been assessed yet.