preact-render-to-string icon indicating copy to clipboard operation
preact-render-to-string copied to clipboard

Denote suspenseful components with comment markers

Open JoviDeCroock opened this issue 1 year ago • 1 comments

Relates to https://github.com/preactjs/preact/issues/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.

JoviDeCroock avatar Jul 13 '24 08:07 JoviDeCroock