webcomponents / polyfills

Web Components Polyfills
BSD 3-Clause "New" or "Revised" License
1.13k stars 165 forks source link

[scoped-custom-element-registry] The scoped registry doesn't work if the DOM already contains the web component when it is defined. #540

Open jpzwarte opened 1 year ago

jpzwarte commented 1 year ago
class Foo extends ScopedElementsMixin(LitElement) {
  static get scopedElements() {
    return { 'x-bar': Bar };
  }
}
  1. Load the polyfill
  2. Have <x-foo> in the DOM
  3. Call customElements.define('x-foo', Foo);
  4. window.customElements.get('x-bar') === Bar

Step 3 should be false, but is true.

If I remove <x-foo> 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 :/