Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[scoped-custom-element-registry] When used, elements defined globally remain undefined #602

Open
tpluscode opened this issue Dec 16, 2024 · 2 comments

Comments

@tpluscode
Copy link

tpluscode commented Dec 16, 2024

Description

In short, I wanted to use globally defined elements in an element which also uses a scoped registry. In my real scenario, the global elements are Shoelace.

Unfortunately, if I use a global element inside a shadow root with scoped registry, it is not created as expected.

Example

https://lit.dev/playground/#gist=aeaab7d7ae68b4341eee63c47d663337

Steps to reproduce

  1. Define my-parent with a scoped custom element registry
  2. In its shadow DOM render a my-child element
  3. Define my-child in global registry

Expected behavior

my-child should be correctly upgraded

Actual behavior

my-child remains undefined unless it is added to the scoped element registry

Version

"@webcomponents/scoped-custom-element-registry": "^0.0.9",
"@open-wc/scoped-elements": "^3.0.5",
@tpluscode tpluscode changed the title [scoped-custom-element-registry] When using scoped custom elements registry, elements defined globally remain undefined [scoped-custom-element-registry] When used, elements defined globally remain undefined Dec 16, 2024
@sorvell
Copy link
Collaborator

sorvell commented Dec 20, 2024

This is by design as per the current proposal. You'll need to re-define the elements in the registry in which you want to use them. To implement this automatically, you could potentially override window.customElements.define to capture the list of defined elements and ensure those are re-defined on any local registry.

Here is an example.

It's better to give feedback on the proposal or the latest version to request an easier way to do this.

@tpluscode
Copy link
Author

Thank you @sorvell for the example. Definitely, there needs to be a simpler way. I will formulate something under that issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants