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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

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: 28872c3

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 3 times, most recently from 4d72e9a to 86b4a54 Compare July 19, 2024 05:28
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