dillon1000/react

Commit

[Float][Fizz][Legacy] hoisted elements no longer emit before `<html>` in legacy apis such as `renderToString()` (#27269)

renderToString is a legacy server API which used a trick to avoid having
the DOCTYPE included when rendering full documents by setting the root
formatcontext to HTML_MODE rather than ROOT_HTML_MODE. Previously this
was of little consequence but with Float the Root mode started to be
used for things like determining if we could flush hoistable elements
yet. In issue #27177 we see that hoisted elements can appear before the
<html> tag when using a legacy API `renderToString`.

This change exports a DOCTYPE from FizzConfigDOM and FizzConfigDOMLegacy
respectively, using an empty chunk in the legacy case. The only runtime
perf cost here is that for legacy APIs there is an extra empty chunk to
write when rendering a top level <html> tag which is trivial enough

Fixes #27177
Browse files
Changed paths3 files
First-parent comparison
M packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js ModifiedM packages/react-dom-bindings/src/server/ReactFizzConfigDOMLegacy.js ModifiedA packages/react-dom/src/__tests__/ReactDOMLegacyFloat-test.js Added
Patch

Files changed

Rendering syntax-highlighted changes…