Skip to content

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

@thescientist13

Description

@thescientist13

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.

Metadata

Metadata

Labels

0.16.0bugSomething isn't workingquestionFurther information is requested

Type

No type

Projects

Status

✅ Done

Relationships

None yet

Development

No branches or pull requests

Issue actions