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.