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

Add ReactDOMClient to ServerIntegrationElements #28134

Merged
merged 4 commits into from
Feb 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Hydration keeps LF from server HTML
  • Loading branch information
Sebastian Silbermann authored and rickhanlonii committed Feb 1, 2024
commit d4a608bb0a8162412e2ae2edf0d4d2ac3d98dc63
Original file line number Diff line number Diff line change
Expand Up @@ -841,17 +841,20 @@ describe('ReactDOMServerIntegration', () => {
'an element with one text child with special characters',
async render => {
const e = await render(<div>{'foo\rbar\r\nbaz\nqux\u0000'}</div>);
if (render === serverRender || render === streamRender) {
if (
render === serverRender ||
render === streamRender ||
render === clientRenderOnServerString
) {
expect(e.childNodes.length).toBe(1);
// Everything becomes LF when parsed from server HTML.
// Everything becomes LF when parsed from server HTML or hydrated.
// Null character is ignored.
expectNode(e.childNodes[0], TEXT_NODE_TYPE, 'foo\nbar\nbaz\nqux');
} else {
expect(e.childNodes.length).toBe(1);
// Client rendering (or hydration) uses JS value with CR.
// Client rendering uses JS value with CR.
// Null character stays.

//TODO: fixme - This is broken
expectNode(
e.childNodes[0],
TEXT_NODE_TYPE,
Expand All @@ -870,21 +873,17 @@ describe('ReactDOMServerIntegration', () => {
{'\r\nbaz\nqux\u0000'}
</div>,
);
if (render === serverRender || render === streamRender) {
if (
render === serverRender ||
render === streamRender ||
render === clientRenderOnServerString
) {
// We have three nodes because there is a comment between them.
expect(e.childNodes.length).toBe(3);
// Everything becomes LF when parsed from server HTML.
// Everything becomes LF when parsed from server HTML or hydrated.
// Null character is ignored.
expectNode(e.childNodes[0], TEXT_NODE_TYPE, 'foo\nbar');
expectNode(e.childNodes[2], TEXT_NODE_TYPE, '\nbaz\nqux');
} else if (render === clientRenderOnServerString) {
// We have three nodes because there is a comment between them.
expect(e.childNodes.length).toBe(3);
// Hydration uses JS value with CR and null character.

//TODO: fixme - This is broken
expectNode(e.childNodes[0], TEXT_NODE_TYPE, 'foo\rbar');
expectNode(e.childNodes[2], TEXT_NODE_TYPE, '\r\nbaz\nqux\u0000');
} else {
expect(e.childNodes.length).toBe(2);
// Client rendering uses JS value with CR and null character.
Expand Down