Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: insert ooo chunks in the proper order #372

Merged
merged 2 commits into from
Jun 13, 2024

Conversation

jacob-ebey
Copy link
Contributor

@jacob-ebey jacob-ebey commented Jun 13, 2024

fix: stop client runtime from being corrupted

This does two things
1.) the current logic to move OOO children doesn't support multiple children, and is kinda just wrong
2.) puts the client OOO runtime into a string to stop corruption by bundlers such as Vite

fix: insert ooo chunks in the proper order
Copy link

changeset-bot bot commented Jun 13, 2024

🦋 Changeset detected

Latest commit: 7f26ca4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
preact-render-to-string Patch

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

Copy link
Member

@JoviDeCroock JoviDeCroock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great spot, thank you! If you have the time mind describing in what way this would fail with multiple children? As we don't have tests it might be good to have some shared knowledge here.

@jacob-ebey
Copy link
Contributor Author

Great spot, thank you! If you have the time mind describing in what way this would fail with multiple children? As we don't have tests it might be good to have some shared knowledge here.

It is currently looping over an array and incrementing the index that it's mutating.
Start with: [0, 1]
Loop 1:
i = 0
get and remove at i ending with [1]
Loop 2:
i = 1
can't get and remove anything at 1 as what was there is now at 0.

The tried and true "iterate until you have no more children" is best in this case. And we just .after() on the previously moved node starting at the island comment.

@JoviDeCroock JoviDeCroock merged commit bebe4bf into preactjs:main Jun 13, 2024
1 check passed
@github-actions github-actions bot mentioned this pull request Jun 13, 2024
@jacob-ebey jacob-ebey deleted the ooo_streaming branch June 21, 2024 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants