-
Notifications
You must be signed in to change notification settings - Fork 9
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
browser warning about "declarative Shadow DOM has not been enabled by includeShadowRoots" #130
Comments
Can confirm converting to use export default class Greeting extends HTMLElement {
connectedCallback() {
if (!this.shadowRoot) {
const template = document.createElement('template');
template.innerHTML = `
<div>
<h1>Hello World!</h1>
</div>
`;
this.attachShadow({ mode: 'open' });
this.shadowRoot.appendChild(template.content.cloneNode(true));
}
}
}
customElements.define('app-greeting', Greeting); If we do something like this though, then we will get the error and we will have to use export default class Greeting extends HTMLElement {
connectedCallback() {
if (!this.shadowRoot) {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
<div>
<h1>Hello World!</h1>
</div>
`
}
}
}
customElements.define('app-greeting', Greeting); hmm, looks like it happens even when manually setting So not sure how much this does / doesn't muck with any assumptions we are making about how to construct "dynamic" templates I guess, or at least we should emphasize the work arounds needed if you don't use |
So yeah, for #128 , we can't use Will see if there are some docs to add around this, but not sure there's much more for us to do here at this point. I did open up an issue to the MDN docs about documenting |
Summary
Have been noticing this warning lately in Chrome , like if you go here and click the Load Products button at the bottom of the page
https://greenwood-demo-adapter-vercel.vercel.app/
It doesn't actually seem to be an issue with WCC per se, but rather just how we are loading it on the page? 🤔
https://github.com/ProjectEvergreen/greenwood-demo-adapter-vercel/blob/main/src/pages/index.html#L18C1-L32C14
Interestingly, the same implementation using HTMX does not complain about it.
https://greenwood-htmx.vercel.app/
Details
Per some reading around, it does seem that this is related to the use of
insertAdjacentHTML
, as per these docs, it suggests that it would be required to useDOMParser
insteadI can see for example that HTMX is using
DOMParser
, but just not with theincludeShadowRoots
option.(more context here - whatwg/dom#912 (comment) )
I was seeing some of this behavior even with HTMX as part of the solution for #128 ( see #129) so want to conduct some more tests to arrive at a proper conclusion and if this is just a userland issue, or anything WCC itself actually needs to worry about.
So going to play around with some of our implementations and ascribe any relevant documentation if needed and report back.
The text was updated successfully, but these errors were encountered: