@samitouri / QOS-React-2 / commits / ad091759a9

Revert "Emit reactroot attribute on the first element we discover (#21154)" (#21340)

This reverts commit 266c26ad45c977ecf67e9359809c37da1489ca63.

Sebastian Markbåge committed Apr 23, 2021 at 13:28 UTC ad091759a949747f55e1bad498d19be884d4a654
5 files changed +8 -43
packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js
-4
@@ -117,10 +117,6 @@ describe('ReactDOMFizzServer', () => {
117 // We assume this is a React added ID that's a non-visual implementation detail.
118 continue;
119 }
120 - if (attributes[i].name === 'data-reactroot') {
121 - // We ignore React injected attributes.
122 - continue;
123 - }
120 props[attributes[i].name] = attributes[i].value;
121 }
122 props.children = getVisibleChildren(node);
packages/react-dom/src/__tests__/ReactDOMFizzServerBrowser-test.js
+2 -4
@@ -55,9 +55,7 @@ describe('ReactDOMFizzServer', () => {
55 <div>hello world</div>,
56 );
57 const result = await readResult(stream);
58 - expect(result).toMatchInlineSnapshot(
59 - `"<div data-reactroot=\\"\\">hello world</div>"`,
60 - );
58 + expect(result).toMatchInlineSnapshot(`"<div>hello world</div>"`);
59 });
60
61 // @gate experimental
@@ -96,7 +94,7 @@ describe('ReactDOMFizzServer', () => {
94
95 const result = await readResult(stream);
96 expect(result).toMatchInlineSnapshot(
99 - `"<div data-reactroot=\\"\\"><!--$-->Done<!-- --><!--/$--></div>"`,
97 + `"<div><!--$-->Done<!-- --><!--/$--></div>"`,
98 );
99 });
100
packages/react-dom/src/__tests__/ReactDOMFizzServerNode-test.js
+3 -5
@@ -65,9 +65,7 @@ describe('ReactDOMFizzServer', () => {
65 );
66 startWriting();
67 jest.runAllTimers();
68 - expect(output.result).toMatchInlineSnapshot(
69 - `"<div data-reactroot=\\"\\">hello world</div>"`,
70 - );
68 + expect(output.result).toMatchInlineSnapshot(`"<div>hello world</div>"`);
69 });
70
71 // @gate experimental
@@ -84,7 +82,7 @@ describe('ReactDOMFizzServer', () => {
82 // Then React starts writing.
83 startWriting();
84 expect(output.result).toMatchInlineSnapshot(
87 - `"<!doctype html><html><head><title>test</title><head><body><div data-reactroot=\\"\\">hello world</div>"`,
85 + `"<!doctype html><html><head><title>test</title><head><body><div>hello world</div>"`,
86 );
87 });
88
@@ -132,7 +130,7 @@ describe('ReactDOMFizzServer', () => {
130 // Then React starts writing.
131 startWriting();
132 expect(output.result).toMatchInlineSnapshot(
135 - `"<!doctype html><html><head><title>test</title><head><body><div data-reactroot=\\"\\"><!--$-->Done<!-- --><!--/$--></div>"`,
133 + `"<!doctype html><html><head><title>test</title><head><body><div><!--$-->Done<!-- --><!--/$--></div>"`,
134 );
135 });
136
packages/react-dom/src/server/ReactDOMServerFormatConfig.js
+1 -26
@@ -32,7 +32,6 @@ import {
32 OVERLOADED_BOOLEAN,
33 NUMERIC,
34 POSITIVE_NUMERIC,
35 - ROOT_ATTRIBUTE_NAME,
35 } from '../shared/DOMProperty';
36 import {isUnitlessNumber} from '../shared/CSSProperty';
37
@@ -64,7 +63,6 @@ export type ResponseState = {
63 sentCompleteSegmentFunction: boolean,
64 sentCompleteBoundaryFunction: boolean,
65 sentClientRenderFunction: boolean,
67 - hasEmittedRoot: boolean,
66 };
67
68 // Allows us to keep track of what we've already written so we can refer back to it.
@@ -81,7 +79,6 @@ export function createResponseState(
79 sentCompleteSegmentFunction: false,
80 sentCompleteBoundaryFunction: false,
81 sentClientRenderFunction: false,
84 - hasEmittedRoot: false,
82 };
83 }
84
@@ -102,7 +99,7 @@ type InsertionMode = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
99
100 // Lets us keep track of contextual state and pick it back up after suspending.
101 export type FormatContext = {
105 - insertionMode: InsertionMode, // svg/html/mathml/table
102 + insertionMode: InsertionMode, // root/svg/html/mathml/table
103 selectedValue: null | string | Array<string>, // the selected value(s) inside a <select>, or null outside <select>
104 };
105
@@ -511,19 +508,6 @@ const endOfStartTagSelfClosing = stringToPrecomputedChunk('/>');
508 const idAttr = stringToPrecomputedChunk(' id="');
509 const attrEnd = stringToPrecomputedChunk('"');
510
514 -const reactRootAttribute = stringToPrecomputedChunk(
515 - ' ' + ROOT_ATTRIBUTE_NAME + '=""',
516 -);
517 -function pushReactRoot(
518 - target: Array<Chunk | PrecomputedChunk>,
519 - responseState: ResponseState,
520 -): void {
521 - if (!responseState.hasEmittedRoot) {
522 - responseState.hasEmittedRoot = true;
523 - target.push(reactRootAttribute);
524 - }
525 -}
526 -
511 function pushID(
512 target: Array<Chunk | PrecomputedChunk>,
513 responseState: ResponseState,
@@ -657,7 +641,6 @@ function pushStartSelect(
641 if (assignID !== null) {
642 pushID(target, responseState, assignID, props.id);
643 }
660 - pushReactRoot(target, responseState);
644
645 target.push(endOfStartTag);
646 pushInnerHTML(target, innerHTML, children);
@@ -772,7 +755,6 @@ function pushStartOption(
755 if (assignID !== null) {
756 pushID(target, responseState, assignID, props.id);
757 }
775 - pushReactRoot(target, responseState);
758
759 target.push(endOfStartTag);
760 return children;
@@ -860,7 +842,6 @@ function pushInput(
842 if (assignID !== null) {
843 pushID(target, responseState, assignID, props.id);
844 }
863 - pushReactRoot(target, responseState);
845
846 target.push(endOfStartTagSelfClosing);
847 return null;
@@ -925,7 +906,6 @@ function pushStartTextArea(
906 if (assignID !== null) {
907 pushID(target, responseState, assignID, props.id);
908 }
928 - pushReactRoot(target, responseState);
909
910 target.push(endOfStartTag);
911
@@ -1002,7 +982,6 @@ function pushSelfClosing(
982 if (assignID !== null) {
983 pushID(target, responseState, assignID, props.id);
984 }
1005 - pushReactRoot(target, responseState);
985
986 target.push(endOfStartTagSelfClosing);
987 return null;
@@ -1039,7 +1018,6 @@ function pushStartMenuItem(
1018 if (assignID !== null) {
1019 pushID(target, responseState, assignID, props.id);
1020 }
1042 - pushReactRoot(target, responseState);
1021
1022 target.push(endOfStartTag);
1023 return null;
@@ -1078,7 +1056,6 @@ function pushStartGenericElement(
1056 if (assignID !== null) {
1057 pushID(target, responseState, assignID, props.id);
1058 }
1081 - pushReactRoot(target, responseState);
1059
1060 target.push(endOfStartTag);
1061 pushInnerHTML(target, innerHTML, children);
@@ -1143,7 +1120,6 @@ function pushStartCustomElement(
1120 if (assignID !== null) {
1121 pushID(target, responseState, assignID, props.id);
1122 }
1146 - pushReactRoot(target, responseState);
1123
1124 target.push(endOfStartTag);
1125 pushInnerHTML(target, innerHTML, children);
@@ -1185,7 +1161,6 @@ function pushStartPreformattedElement(
1161 if (assignID !== null) {
1162 pushID(target, responseState, assignID, props.id);
1163 }
1188 - pushReactRoot(target, responseState);
1164
1165 target.push(endOfStartTag);
1166
packages/react-server-dom-relay/src/__tests__/ReactDOMServerFB-test.internal.js
+2 -4
@@ -45,9 +45,7 @@ describe('ReactDOMServerFB', () => {
45 },
46 });
47 const result = readResult(stream);
48 - expect(result).toMatchInlineSnapshot(
49 - `"<div data-reactroot=\\"\\">hello world</div>"`,
50 - );
48 + expect(result).toMatchInlineSnapshot(`"<div>hello world</div>"`);
49 });
50
51 it('emits all HTML as one unit if we wait until the end to start', async () => {
@@ -81,7 +79,7 @@ describe('ReactDOMServerFB', () => {
79
80 const result = readResult(stream);
81 expect(result).toMatchInlineSnapshot(
84 - `"<div data-reactroot=\\"\\"><!--$-->Done<!-- --><!--/$--></div>"`,
82 + `"<div><!--$-->Done<!-- --><!--/$--></div>"`,
83 );
84 });
85