Repository navigation
fix(#2366): rehydrated components added twice - #2508
Closed
peterpeterparker wants to merge 3 commits into
Closed
peterpeterparker wants to merge 3 commits into
peterpeterparker wants to merge 3 commits into
Conversation
Contributor
|
Thanks a lot for the PR! it was merge in this commit: e152773 |
Contributor
Author
|
Awesome! Thx :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduction
This is my suggestion to solve #2366. I am honestly not sure it is the proper solution and would appreciate any hints.
I am also not against that PR being rejected as long as the problem, I communicated in April 2020, finds a solution.
Indeed I am not able to upgrade our applications and therefore are kind of blocked with Stencil v1.8. I would be really happy to upgrade.
Moreover, I noticed that prerendering solved would enhance by more than 10% our load time, therefore, more really more than in need and looking forward to a solution.
Current behavior:
With prerendering, components are not rehydrated and are added twice to the DOM
Expected behavior:
Components are rehydrated with a single instance to the DOM
Root cause of issue
I mostly tested the issue with the
ion-router, more precisely noticed the issue with theion-navand a "page" (app-home) being added twice two the DOM.I did a comparison with the Stencil router, with which I did not face the issue, and noticed that the root case was the missing component reference (
c-id).Concretely, currently these elements would be prerendered as following:
But if they would be added as following, then the issue would be solved:
Adding
c-id=14.0.0.1was the solution here.A spent some time debugging
vdom-annotation.tsand figured out that this "missing annotation" was a result of the VDOM representation.Indeed, if the
ion-navis referenced asparentof theapp-home, the contrary was not correct, theapp-homewas not referenced aschildof theion-navbut itsslot.ion-nav element:
app-home element:
Suggestion of solution
As both elements are kind of not fully linked, my idea is to add a post processing to the insertion of the annotation which checks if the node as received a
c-idand if not, as a a parent which contains acommentfor the slot. If so, it calculate thec-idand adds the attributeConclusion
As I said in my introduction, my solution might not be correct, it of course works out according my tests but you might find some reason why not. In such case, I am not against rejecting this PR, a cool, but would really, really appreciate if we can move forward with prerendering while using the Ionic Router.