fix hydration in solid renderer#8365
Merged
natemoo-re merged 2 commits intowithastro:mainfrom Sep 6, 2023
Merged
Conversation
🦋 Changeset detectedLatest commit: ae4ef71 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
natemoo-re
reviewed
Sep 1, 2023
Member
natemoo-re
left a comment
There was a problem hiding this comment.
Thanks @ryansolid! I'll give this a more thorough test run, but the code looks totally reasonable.
🙌 Appreciate you jumping on this
natemoo-re
approved these changes
Sep 6, 2023
Member
natemoo-re
left a comment
There was a problem hiding this comment.
Thank you! No notes, this looks great. Merging as-is.
Merged
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.
Changes
I was playing on stream and noticed top-level fragments weren't working properly in Solid Astro integration. Duplicated elements and other weirdness. On further exploration I realized this is because the renderer always creates new DOM nodes by cloning so it can't match them.
I then noticed that the hydration check wasn't working because it was being done before any hydrate calls were being done top-level. This meant it was always false so we were always creating the nodes as if client rendered as well.
Also hierarchical children weren't working as we'd consume all descendant slots and they'd override the parent. I'm hoping this treewalker is fine for performance but if you have ideas open to that.
The solution might seem a bit odd but given visibility changes (ie.. islands controlling when to render slots) I think that creating vs consuming isn't an either/or like it was before but per slot. We try to fill from the DOM first and failing that we fill out the templates. I suppose we could make it do that lazily for even more performance but them prop handling needs some more work.
Testing
Honestly I only tested this in my Hackernews project which let me test recursion and visibility show and hide. But I didn't test client only or other modes so there could be gaps.
Docs
This shouldn't require docs changes. The API is the same. It just fixes a bunch of random bugs and should improve performance for the shown element case.