React version: 18.3.0-next-4bf2113a1-20230206
Steps To Reproduce
ReactDOM.render into a document container
Link to code example: https://codesandbox.io/s/react-next-legacy-render-crashes-when-rendering-html-jqdut3?file=/src/index.js
The current behavior
Throws with
React expected an <html> element (document.documentElement) to exist in the Document but one was not found. React never removes the documentElement for any Document it renders into so the cause is likely in some other script running on this page.
ReactDOM.render clears the container before rendering into it. But with the new HostSingletons (#25426) we expect an existing documentElement.
The odd part is that it seems like #25426 affected the @next release even though enableHostSingletons is disabled for that release.
/cc @gnoff
The expected behavior
No crash like in react-dom@18.2.0: https://codesandbox.io/s/react-next-legacy-render-crashes-when-rendering-html-forked-977biy