GeezerVison is showing github.com — [Fizz] Random Fixes (#21277) · react/react@96d00b9
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactDOMFizzServerBrowser-test.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -56,7 +56,7 @@ describe('ReactDOMFizzServer', () => { | 56 | 56 | ); | 57 | 57 | const result = await readResult(stream); | 58 | 58 | expect(result).toMatchInlineSnapshot( | 59 | | - `"<div data-reactroot=\\"\\">hello world<!-- --></div>"`, | | 59 | + `"<div data-reactroot=\\"\\">hello world</div>"`, | 60 | 60 | ); | 61 | 61 | }); | 62 | 62 |
| |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactDOMFizzServerNode-test.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -66,7 +66,7 @@ describe('ReactDOMFizzServer', () => { | 66 | 66 | startWriting(); | 67 | 67 | jest.runAllTimers(); | 68 | 68 | expect(output.result).toMatchInlineSnapshot( | 69 | | - `"<div data-reactroot=\\"\\">hello world<!-- --></div>"`, | | 69 | + `"<div data-reactroot=\\"\\">hello world</div>"`, | 70 | 70 | ); | 71 | 71 | }); | 72 | 72 |
| @@ -84,7 +84,7 @@ describe('ReactDOMFizzServer', () => { | 84 | 84 | // Then React starts writing. | 85 | 85 | startWriting(); | 86 | 86 | expect(output.result).toMatchInlineSnapshot( | 87 | | - `"<!doctype html><html><head><title>test</title><head><body><div data-reactroot=\\"\\">hello world<!-- --></div>"`, | | 87 | + `"<!doctype html><html><head><title>test</title><head><body><div data-reactroot=\\"\\">hello world</div>"`, | 88 | 88 | ); | 89 | 89 | }); | 90 | 90 |
| |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/server/ReactDOMServerFormatConfig.js +15-4Lines changed: 15 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -563,7 +563,9 @@ function pushInnerHTML( | 563 | 563 | 'for more information.', | 564 | 564 | ); | 565 | 565 | const html = innerHTML.__html; | 566 | | - target.push(stringToChunk(html)); | | 566 | + if (html !== null && html !== undefined) { | | 567 | + target.push(stringToChunk('' + html)); | | 568 | + } | 567 | 569 | } | 568 | 570 | } | 569 | 571 |
| @@ -1079,6 +1081,12 @@ function pushStartGenericElement( | 1079 | 1081 |
| 1080 | 1082 | target.push(endOfStartTag); | 1081 | 1083 | pushInnerHTML(target, innerHTML, children); | | 1084 | + if (typeof children === 'string') { | | 1085 | + // Special case children as a string to avoid the unnecessary comment. | | 1086 | + // TODO: Remove this special case after the general optimization is in place. | | 1087 | + target.push(stringToChunk(encodeHTMLTextNode(children))); | | 1088 | + return null; | | 1089 | + } | 1082 | 1090 | return children; | 1083 | 1091 | } | 1084 | 1092 |
| @@ -1205,10 +1213,13 @@ function pushStartPreformattedElement( | 1205 | 1213 | 'for more information.', | 1206 | 1214 | ); | 1207 | 1215 | const html = innerHTML.__html; | 1208 | | - if (typeof html === 'string' && html[0] === '\n') { | 1209 | | - target.push(leadingNewline); | | 1216 | + if (html !== null && html !== undefined) { | | 1217 | + if (typeof html === 'string' && html.length > 0 && html[0] === '\n') { | | 1218 | + target.push(leadingNewline, stringToChunk(html)); | | 1219 | + } else { | | 1220 | + target.push(stringToChunk('' + html)); | | 1221 | + } | 1210 | 1222 | } | 1211 | | - target.push(stringToChunk(html)); | 1212 | 1223 | } | 1213 | 1224 | if (typeof children === 'string' && children[0] === '\n') { | 1214 | 1225 | target.push(leadingNewline); | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-server/src/ReactFizzServer.js +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -767,7 +767,8 @@ function renderForwardRef( | 767 | 767 | props: Object, | 768 | 768 | ref: any, | 769 | 769 | ): void { | 770 | | - renderWithHooks(request, task, type, props, ref); | | 770 | + const children = renderWithHooks(request, task, type.render, props, ref); | | 771 | + renderNodeDestructive(request, task, children); | 771 | 772 | } | 772 | 773 |
| 773 | 774 | function renderMemo( | |
|