[Fizz] Random Fixes (#21277)
This commit is contained in:
parent
0e100ed00f
commit
96d00b9bba
|
@ -56,7 +56,7 @@ describe('ReactDOMFizzServer', () => {
|
|||
);
|
||||
const result = await readResult(stream);
|
||||
expect(result).toMatchInlineSnapshot(
|
||||
`"<div data-reactroot=\\"\\">hello world<!-- --></div>"`,
|
||||
`"<div data-reactroot=\\"\\">hello world</div>"`,
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ describe('ReactDOMFizzServer', () => {
|
|||
startWriting();
|
||||
jest.runAllTimers();
|
||||
expect(output.result).toMatchInlineSnapshot(
|
||||
`"<div data-reactroot=\\"\\">hello world<!-- --></div>"`,
|
||||
`"<div data-reactroot=\\"\\">hello world</div>"`,
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -84,7 +84,7 @@ describe('ReactDOMFizzServer', () => {
|
|||
// Then React starts writing.
|
||||
startWriting();
|
||||
expect(output.result).toMatchInlineSnapshot(
|
||||
`"<!doctype html><html><head><title>test</title><head><body><div data-reactroot=\\"\\">hello world<!-- --></div>"`,
|
||||
`"<!doctype html><html><head><title>test</title><head><body><div data-reactroot=\\"\\">hello world</div>"`,
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -563,7 +563,9 @@ function pushInnerHTML(
|
|||
'for more information.',
|
||||
);
|
||||
const html = innerHTML.__html;
|
||||
target.push(stringToChunk(html));
|
||||
if (html !== null && html !== undefined) {
|
||||
target.push(stringToChunk('' + html));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1079,6 +1081,12 @@ function pushStartGenericElement(
|
|||
|
||||
target.push(endOfStartTag);
|
||||
pushInnerHTML(target, innerHTML, children);
|
||||
if (typeof children === 'string') {
|
||||
// Special case children as a string to avoid the unnecessary comment.
|
||||
// TODO: Remove this special case after the general optimization is in place.
|
||||
target.push(stringToChunk(encodeHTMLTextNode(children)));
|
||||
return null;
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
|
@ -1205,10 +1213,13 @@ function pushStartPreformattedElement(
|
|||
'for more information.',
|
||||
);
|
||||
const html = innerHTML.__html;
|
||||
if (typeof html === 'string' && html[0] === '\n') {
|
||||
target.push(leadingNewline);
|
||||
if (html !== null && html !== undefined) {
|
||||
if (typeof html === 'string' && html.length > 0 && html[0] === '\n') {
|
||||
target.push(leadingNewline, stringToChunk(html));
|
||||
} else {
|
||||
target.push(stringToChunk('' + html));
|
||||
}
|
||||
}
|
||||
target.push(stringToChunk(html));
|
||||
}
|
||||
if (typeof children === 'string' && children[0] === '\n') {
|
||||
target.push(leadingNewline);
|
||||
|
|
|
@ -767,7 +767,8 @@ function renderForwardRef(
|
|||
props: Object,
|
||||
ref: any,
|
||||
): void {
|
||||
renderWithHooks(request, task, type, props, ref);
|
||||
const children = renderWithHooks(request, task, type.render, props, ref);
|
||||
renderNodeDestructive(request, task, children);
|
||||
}
|
||||
|
||||
function renderMemo(
|
||||
|
|
Loading…
Reference in New Issue