You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support ShadowDom Polyfills (not just Scoped Fallback) #2012
On IE11, when you click "Like" the Stencil component fails to render with the template:
On Chrome, when you click "Like" the Stencil component shows the slot as expected:
FWIW, this repro worked fine when we created the same Web Component with LitElement.
I think the right fix for this is to support using Shadow Dom polyfills instead of the fallback to scoped approach.
We tried to load the ShadowDom polyfills ourselves, but ran into issues with CSS selectors. The scoped CSS rewrites don't happen when the polyfills exist. Stencil should provide us with a way to enable ShadowDom polyfills correctly so that slots and CSS work well.
The same problem here, I'm using the version 1.8.1, in my case, I'm make a library like Bootstrap, and all my componentes have this problem in the SSR in Firefox and Chrome.
Stencil should just remove the "scope fallback code" and just let consumers use webcomponentsjs polyfills if needed. That would likely help with these issues.
There are three work-arounds that will render correctly:
wrap each conditional result in same tag type:
<my-component>{this.state.liked ? (<p>Button was clicked!</p>) : (<p>Click the button</p>)}</my-component>
wrap the conditional expression in an extraneous tag like span or div (not ideal for semantic markup, but gets the job done):
<my-component><div>{this.state.liked ? (<p>Button was clicked!</p>) : ("Click the button")}</div></my-component>
use <React.Fragment> (or the shorthand <>…</>) for simple cases with just string messages where you don’t want extraneous markup:
<my-component>{this.state.liked ? (<React.Fragment>Button was clicked!</React.Fragment>) : (<React.Fragment>Click the button</React.Fragment>)}</my-component>
Basically anything that ensures the first child node that gets relocated to the slot remains the same type could work. I suspect the issue is because react's internal fiber tree probably has the relocated child node at different position from where it ultimately ends up after slot relocation. Then after state change, reconciliation detects tag type change so react tries to remove child and append new child based on incorrect fiber model of committed dom structure.
This commit addressed a bug with appendChild and stencil's light-dom slot logic. Not sure if that fix also addresses this issue and have not tested it myself yet.
Also, it seems stencil's slot relocation logic correctly renders surrounding template elements on initial render, but not on update, so maybe something in connectedCallback or in the relocateSlotContent logic needs to be refreshed when children change.
the same is happening in Angular when using innerHTML directive. But if you wrap it within one native dom element it's working
So this doesn't work in Edge/IE:
I apologize that it took so long for a member of the team to acknowledge this ticket. With Stencil v3, we've officially deprecated support for IE 11/older versions of Edge. At this time, we're not looking to add support for ShadowDom polyfills. As such, I'm going to close this out. Again, I apologize for the lack of response from the team here.
Activity
schadenn commentedon Nov 22, 2019
Opened #2031 with a quick fix to enable forcing shadow Dom in IE - tested it in our codebase together with @webcomponents/webcomponentsjs
patrickalima98 commentedon Nov 23, 2019
The same problem here, I'm using the version 1.8.1, in my case, I'm make a library like Bootstrap, and all my componentes have this problem in the SSR in Firefox and Chrome.
markcellus commentedon Jan 9, 2020
FWIW, I definitely agree with @schadenn's comment in #2031 (comment).
Stencil should just remove the "scope fallback code" and just let consumers use webcomponentsjs polyfills if needed. That would likely help with these issues.
sschottler commentedon Feb 2, 2020
There are three work-arounds that will render correctly:
<React.Fragment>(or the shorthand<>…</>) for simple cases with just string messages where you don’t want extraneous markup:Basically anything that ensures the first child node that gets relocated to the slot remains the same type could work. I suspect the issue is because react's internal fiber tree probably has the relocated child node at different position from where it ultimately ends up after slot relocation. Then after state change, reconciliation detects tag type change so react tries to remove child and append new child based on incorrect fiber model of committed dom structure.
This commit addressed a bug with appendChild and stencil's light-dom slot logic. Not sure if that fix also addresses this issue and have not tested it myself yet.
Also, it seems stencil's slot relocation logic correctly renders surrounding template elements on initial render, but not on update, so maybe something in connectedCallback or in the relocateSlotContent logic needs to be refreshed when children change.
hypery2k commentedon Feb 12, 2020
the same is happening in Angular when using
innerHTMLdirective. But if you wrap it within one native dom element it's workingSo this doesn't work in Edge/IE:
But this does:
Sanderand commentedon Nov 17, 2020
Is there an update on this issue? It's still relevant for the latest Stencil version (2.3.0)
rwaskiewicz commentedon Sep 6, 2023
Hey there 👋
I apologize that it took so long for a member of the team to acknowledge this ticket. With Stencil v3, we've officially deprecated support for IE 11/older versions of Edge. At this time, we're not looking to add support for ShadowDom polyfills. As such, I'm going to close this out. Again, I apologize for the lack of response from the team here.