Prerequisites
Stencil Version
>=4.25.0
Current Behavior
For stencil versions >=4.25.0, (looks like only with experimentalSlotFixes enabled in the stencil config), if a scoped component has a wrapper around it's slot, such as:
<Host>
<div class="slot-wrapper">
<slot></slot>
</div>
</Host>
then, any element slotted into this scoped element will not return the expected value when trying to get it's parentNode.
Example:
<scoped-parent>
<slotted-content></slotted-content>
</scoped-parent>
In the code above the slotted-content element will return scoped-parent as it's parentNode and div as it's parentElement.
Expected Behavior
The expected behavior is that both the parentNode and parentElement for the slotted-content in the aforementioned example, should return the slot wrapper div element.
When inspecting the DOM you will see:
<scoped-parent>
<div class="slot-wrapper">
<slotted-content></slotted-content>
</div>
</scoped-parent>
so it's expected that the div is both the parentNode and parentElement
System Info
System: node 21.1.0
Platform: darwin (23.5.0)
CPU Model: Apple M1 Pro (8 cpus)
Compiler: /Users/andrebarrientos/Documents/repos/stenciljs-scoped-parentNode-issue/parent-node-issue/node_modules/@stencil/core/compiler/stencil.js
Build: 1737602259
Stencil: 4.25.0 🏅
TypeScript: 5.5.4
Rollup: 2.56.3
Parse5: 7.1.2
jQuery: 4.0.0-pre
Terser: 5.31.1
Steps to Reproduce
Any scoped element that wraps it's slot internally will have this issue.
Steps to reproduce with my code reproduction:
git clone git@github.com:AndreBarr/stenciljs-scoped-parentNode-issue.git
cd stenciljs-scoped-parentNode-issue/parent-node-issue
npm i
npm run start
- Open the devtools in the demo environment
- Click the Get parentNode and parentElement button.
- In the console you will see two tables, one representing elements slotted into a scoped parent and one for a shadowed parent.
- Notice that the parentNode and parentElement values are mismatched for the scoped parent.
Code Reproduction URL
https://github.com/AndreBarr/stenciljs-scoped-parentNode-issue/tree/main
Additional Information
No response
Prerequisites
Stencil Version
>=4.25.0
Current Behavior
For stencil versions >=4.25.0, (looks like only with experimentalSlotFixes enabled in the stencil config), if a scoped component has a wrapper around it's slot, such as:
then, any element slotted into this scoped element will not return the expected value when trying to get it's parentNode.
Example:
In the code above the
slotted-contentelement will returnscoped-parentas it's parentNode anddivas it's parentElement.Expected Behavior
The expected behavior is that both the parentNode and parentElement for the
slotted-contentin the aforementioned example, should return the slot wrapperdivelement.When inspecting the DOM you will see:
so it's expected that the div is both the parentNode and parentElement
System Info
System: node 21.1.0 Platform: darwin (23.5.0) CPU Model: Apple M1 Pro (8 cpus) Compiler: /Users/andrebarrientos/Documents/repos/stenciljs-scoped-parentNode-issue/parent-node-issue/node_modules/@stencil/core/compiler/stencil.js Build: 1737602259 Stencil: 4.25.0 🏅 TypeScript: 5.5.4 Rollup: 2.56.3 Parse5: 7.1.2 jQuery: 4.0.0-pre Terser: 5.31.1Steps to Reproduce
Any scoped element that wraps it's slot internally will have this issue.
Steps to reproduce with my code reproduction:
git clone git@github.com:AndreBarr/stenciljs-scoped-parentNode-issue.gitcd stenciljs-scoped-parentNode-issue/parent-node-issuenpm inpm run startCode Reproduction URL
https://github.com/AndreBarr/stenciljs-scoped-parentNode-issue/tree/main
Additional Information
No response