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

DOM Shim is automatically inferring serializable option as true when calling attachShadow #179

Open
thescientist13 opened this issue Dec 2, 2024 · 0 comments
Assignees
Labels
0.16.0 bug Something isn't working
Milestone

Comments

@thescientist13
Copy link
Member

thescientist13 commented Dec 2, 2024

Type of Change

Bug

Summary

To help facilitate the contributions and enhancements around #177 and #170 , it was still an open item that users would not have to opt-in to auto-wrapping of the <template> tag when instantiating their Shadow Root in a custom element.

To illustrate, just doing this will automatically wrap the output of WCC in a <template> tag for you

this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = '<p>html goes here</p>';

This is based on a combination of Web APIs that we understand to work in tandem, which we are not accurately honoring ( though say some may say that honoring the spec would come at the expense of developer experience ;) )

For getHTML the spec states that we can consider serializing shadow roots if serializable is set to true, e.g.

this.attachShadow({ mode: 'open', serializable: true });
this.shadowRoot.innerHTML = '<p>html goes here</p>';

I am OK with WCC automatically setting serializableShadowRoots: true

Details

I am open to being persuaded to support implied auto-wrapping, but would rather allow a compiler level option to set these automatically instead (through a new issue / PR) but for the sake of this bug report, the expectation would be that the DOM Shim only serializes if it detects serializable: true has been set in the custom element.

This might require "unbreaking" a couple test cases that were changed in #177 but that is fine. Either way we should follow the specs or otherwise document deviations from spec'd behavior, in which case if I am talked out of this, we should document on the home page docs that we do this under attachShadow in the Key Features section.

@thescientist13 thescientist13 added the bug Something isn't working label Dec 2, 2024
@thescientist13 thescientist13 added this to the 1.0 milestone Dec 2, 2024
@thescientist13 thescientist13 self-assigned this Dec 2, 2024
@thescientist13 thescientist13 changed the title DOM Shim is automatically inferring serializable as true when calling attachShadow DOM Shim is automatically inferring serializable option as true when calling attachShadow Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.16.0 bug Something isn't working
Projects
Status: 🔖 Ready
Development

No branches or pull requests

1 participant