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

fix: Custom Elements - fix crash, add Shadow DOM option #257

Merged
merged 2 commits into from Jan 3, 2023

Conversation

developit
Copy link
Contributor

Description

The current Web Components compiler produces an invalid Custom Element. When instantiated via document.createElement('icon-a-b'), it will throw an error: "Failed to construct 'CustomElement': The result must not have children". The recommended solution from the CE spec is to append light DOM children in connectedCallback, so I've made that change here. I've also added a shadow option to have the generated CE use an open Shadow Root instead of light DOM children.

Linked Issues

(none)

Additional context

I made this change via GH web, so it doesn't include any of the TypeScript definition changes for the new options.shadow boolean.

…dow DOM

The current Web Components compiler produces an invalid Custom Element. When instantiated via `document.createElement('icon-a-b')`, it will throw an error: "Failed to construct 'CustomElement': The result must not have children".  The recommended solution from the CE spec is to append light DOM children in `connectedCallback`, so I've made that change here. I've also added a `shadow` option to have the generated CE use an open Shadow Root instead of light DOM children.
@antfu antfu changed the title Custom Elements: fix crash, add Shadow DOM option fix: Custom Elements - fix crash, add Shadow DOM option Jan 3, 2023
@antfu antfu merged commit 0b5b988 into unplugin:main Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants