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

[Fizz] Assign an ID to the first DOM element in a fallback or insert a dummy (and testing infra) #21020

Merged
merged 4 commits into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions packages/react-dom/src/server/ReactDOMServerFormatConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export function writeEndSuspenseBoundary(destination: Destination): boolean {
const startSegment = stringToPrecomputedChunk('<div hidden id="');
const startSegment2 = stringToPrecomputedChunk('S:');
const startSegment3 = stringToPrecomputedChunk('">');
const endSegment = stringToPrecomputedChunk('"></div>');
const endSegment = stringToPrecomputedChunk('</div>');
export function writeStartSegment(
destination: Destination,
id: number,
Expand Down Expand Up @@ -297,7 +297,7 @@ export function writeCompletedSegmentInstruction(
responseState: ResponseState,
contentSegmentID: number,
): boolean {
if (responseState.sentCompleteSegmentFunction) {
if (!responseState.sentCompleteSegmentFunction) {
// The first time we write this, we'll need to include the full implementation.
responseState.sentCompleteSegmentFunction = true;
writeChunk(destination, completeSegmentScript1Full);
Expand Down Expand Up @@ -328,7 +328,7 @@ export function writeCompletedBoundaryInstruction(
boundaryID: SuspenseBoundaryID,
contentSegmentID: number,
): boolean {
if (responseState.sentCompleteBoundaryFunction) {
if (!responseState.sentCompleteBoundaryFunction) {
// The first time we write this, we'll need to include the full implementation.
responseState.sentCompleteBoundaryFunction = true;
writeChunk(destination, completeBoundaryScript1Full);
Expand Down Expand Up @@ -362,7 +362,7 @@ export function writeClientRenderBoundaryInstruction(
responseState: ResponseState,
boundaryID: SuspenseBoundaryID,
): boolean {
if (responseState.sentClientRenderFunction) {
if (!responseState.sentClientRenderFunction) {
// The first time we write this, we'll need to include the full implementation.
responseState.sentClientRenderFunction = true;
writeChunk(destination, clientRenderScript1Full);
Expand Down
8 changes: 8 additions & 0 deletions packages/react-server/src/ReactFizzServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,14 @@ function renderNode(
pushTextInstance(segment.chunks, node);
return;
}

if (Array.isArray(node)) {
for (let i = 0; i < node.length; i++) {
renderNode(request, parentBoundary, segment, node[i]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, so nice to be able to use the actual JS stack 😆

}
return;
}

if (
typeof node !== 'object' ||
!node ||
Expand Down