Repository navigation
Description
Stencil version:
@stencil/[email protected]
I'm submitting a:
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/
Current behavior:
When using the generated hydrate script in an SSR-rendered app some elements are incorrectly duplicated. (The blue square to the right of my button is a duplicated, empty button)
Expected behavior:
Hydrated components would only render once.
Steps to reproduce:
I've had trouble narrowing this down to a specific cause. You can reproduce it using this repo I put together: https://github.com/cloudfour/stencil-ssr-bug-reproduction
This is a simplified version of a project I'm working on which is why it is structured the way it is. I have a subdirectory housing my stencil components. Adjacent to that I have another subdirectory housing my express app. From the root directory you can run a number of commands.
In order to build my express app, I build my stencil components, copy the output into the express app, and then run the express app.
- Check out that repo
- Install dependencies for the components:
cd stencil-components,npm i,cd ..(from root) - Install dependencies for my app:
cd express-app,npm i,cd ..(from root) - Build my components and copy them into my express app
npm run build(from root) - Run my express app:
npm run start:express(from root) - Navigate to express app (http://localhost:3000/)
- See that the button has been duplicated
I had also reproduced this using the prerender option in my project, but didn't set up a sample repository for that. Let me know if that would be helpful.
Related code:
See repro directory above
Other information:
I originally reported this as a comment on #2366 . @peterpeterparker was kind enough to take a look and help me debug it. He suggested a change to vdom-annotations which seemed to work for me: #2366 (comment)
He asked me to open a new issue since his original issue had been resolved.
Thanks for the great library! I love working with Stencil and am excited to get my SSR working! Let me know if you need any other info from me 🙂


Activity
chenyulun commentedon Dec 7, 2020
"@stencil/core": "^2.3.0",If the parent tag is larger than the child tag, the child tag repeats,for example
Tag size relationship:
c4-q>c4-page>c4-buttonThe tag that causes the error is nested as follows:
The tags that can be executed correctly are nested as follows:
First of all, record the scene of repetition. If I have time, I will study the reason(先记录一下复现的场景,有空的话我会去研究一下原因)
chenyulun commentedon Dec 8, 2020
Repair methods
Add a judgment to 'if (childNodeType)' on 'clientHydrate'. The current 'parentVNode' node will not be added to it
(在
clientHydrate方法上的添加一个if (childNodeType)上添加一个判断if (hostElm !== node && childNodeType),当前node节点不加入到当前parentVNode节点上)I don't know if there will be other effects
by the way: find a bug
c-iddoes not have$index$, Is this the slot tag content?If so, there is no need to deal with their childrenchenyulun commentedon Dec 8, 2020
One more question:
I mentioned earlier that the order in which tags are executed causes problems,
Somehow, the small tag is always executed first, and then the large tag is executed, for example,
c4-button>c4-page;This small tag reads its own
c-idand if into the child vNode;If the label order is as follows
First execute the small tag ,, and delete the
c-idof when changing the quantum node. In this way, will not be added to vnode as a child node when traversing itself again,chenyulun commentedon Dec 8, 2020
@peterpeterparker Come and have a look
chenyulun commentedon Dec 9, 2020
new bug:
shadow:false,The default content in the slot element cannot be processed correctlychenyulun commentedon Dec 9, 2020
fix
chenyulun commentedon Dec 9, 2020
In the non-shadow elements, during the generation of vnodes,
slot-fbcan be resolved into slot, so that there is no need to regenerateslot-fbelements when comparing rootvnodes to improve performancefix code
ionitron-bot commentedon Jan 8, 2021
Thanks for the issue! This issue is being closed due to inactivity. If this is still an issue with the latest version of Stencil, please create a new issue and ensure the template is fully filled out.
Thank you for using Stencil!