Fix Astro components parent-child render order #8187
Merged
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
Fix #8059
Previously, the
renderComponent
API will kick off the render directly, however I didn't notice that component slots are inited eagerly (for head propagation) and it kicked off the rendering of slots eagerly (not good).This PR reverts to the previous technique where the parent will render each child in parallel manually instead. It renders all the child into a buffer first, then flush it out when it's its turn to render.
NOTE: While the benchmark shows that this is faster, it's because I removed the
bufferChunks.length = 0
optimization which seems to do more harm than good for perf. If I ported that, the perf is actually slightly lower because things are less in parallel.Testing
Added a new test
Docs
n/a. bug fix.