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

Denote suspenseful components with comment markers #376

Merged
merged 3 commits into from
Jan 15, 2025

Conversation

JoviDeCroock
Copy link
Member

@JoviDeCroock JoviDeCroock commented Jul 13, 2024

Relates to preactjs/preact#4442

This adds the comments approach described in the RFC, these comments will be used with resumed hydration to correctly allocate the DOM-children required to rehydrate a Suspense boundary. Currently this purposefully excludes streaming renders.

This needs a lot more tests and will probably lead to a major version of RTS and Preact (to be discussed).

The algorithm we'd use in Preact for this would entail us searching for the comment boundary, so in the most ideal scenario this would look like

const excessDomChildren = [null, COMMENT_BEGIN,...theDomNodes, COMMENT_END];

but there will be time where it looks like

const excessDomChildren = [null, COMMENT_BEGIN, 'div', COMMENT_BEGIN, COMMENT_END, COMMENT_END];

due to adjacent suspending children, we'd have to look for 2 end nodes then so the search algorithm would have to count the amount of contained suspensions as well.

Copy link

changeset-bot bot commented Jul 13, 2024

🦋 Changeset detected

Latest commit: 0da840e

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 Minor

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

@JoviDeCroock JoviDeCroock force-pushed the comment-markers branch 4 times, most recently from 7f7b1e7 to b0994fa Compare July 14, 2024 06:57
@JoviDeCroock JoviDeCroock force-pushed the comment-markers branch 2 times, most recently from 5b02ce4 to a9b55f2 Compare January 15, 2025 17:03
@JoviDeCroock JoviDeCroock merged commit 81e7da3 into main Jan 15, 2025
1 check passed
@JoviDeCroock JoviDeCroock deleted the comment-markers branch January 15, 2025 19:56
@github-actions github-actions bot mentioned this pull request Jan 15, 2025
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