Skip to content

Commit 3d56c0e

Browse files
committed
nits and errors
1 parent 8e69ca1 commit 3d56c0e

File tree

2 files changed

+8
-32
lines changed

2 files changed

+8
-32
lines changed

packages/react-dom/src/server/ReactDOMServerFormatConfig.js

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -243,26 +243,6 @@ export function getChildFormatContext(
243243
return parentContext;
244244
}
245245

246-
function isPreambleInsertion(type: string): boolean {
247-
switch (type) {
248-
case 'html':
249-
case 'head': {
250-
return true;
251-
}
252-
}
253-
return false;
254-
}
255-
256-
function isPostambleInsertion(type: string): boolean {
257-
switch (type) {
258-
case 'body':
259-
case 'html': {
260-
return true;
261-
}
262-
}
263-
return false;
264-
}
265-
266246
export type SuspenseBoundaryID = null | PrecomputedChunk;
267247

268248
export const UNINITIALIZED_SUSPENSE_BOUNDARY_ID: SuspenseBoundaryID = null;
@@ -1264,7 +1244,7 @@ function pushStartHead(
12641244
responseState: ResponseState,
12651245
): ReactNodeList {
12661246
// Preamble type is nullable for feature off cases but is guaranteed when feature is on
1267-
target = enableFloat && isPreambleInsertion(tag) ? (preamble: any) : target;
1247+
target = enableFloat ? (preamble: any) : target;
12681248

12691249
return pushStartGenericElement(target, props, tag, responseState);
12701250
}
@@ -1278,7 +1258,7 @@ function pushStartHtml(
12781258
responseState: ResponseState,
12791259
): ReactNodeList {
12801260
// Preamble type is nullable for feature off cases but is guaranteed when feature is on
1281-
target = enableFloat && isPreambleInsertion(tag) ? (preamble: any) : target;
1261+
target = enableFloat ? (preamble: any) : target;
12821262

12831263
if (formatContext.insertionMode === ROOT_HTML_MODE) {
12841264
// If we're rendering the html tag and we're at the root (i.e. not in foreignObject)
@@ -1657,8 +1637,7 @@ export function pushEndInstance(
16571637
case 'body':
16581638
case 'html':
16591639
// Preamble type is nullable for feature off cases but is guaranteed when feature is on
1660-
target =
1661-
enableFloat && isPostambleInsertion(type) ? (postamble: any) : target;
1640+
target = enableFloat ? (postamble: any) : target;
16621641
// Intentional fallthrough
16631642
default: {
16641643
target.push(endTag1, stringToChunk(type), endTag2);

packages/react-server/src/ReactFizzServer.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2081,7 +2081,6 @@ function flushCompletedQueues(
20812081
// we expect the preamble to be tiny and will ignore backpressure
20822082
writeChunk(destination, preamble[i]);
20832083
}
2084-
preamble.length = 0;
20852084
}
20862085

20872086
flushSegment(request, destination, completedRootSegment);
@@ -2159,7 +2158,6 @@ function flushCompletedQueues(
21592158
}
21602159
largeBoundaries.splice(0, i);
21612160
} finally {
2162-
let allComplete = false;
21632161
if (
21642162
request.allPendingTasks === 0 &&
21652163
request.pingedTasks.length === 0 &&
@@ -2168,20 +2166,16 @@ function flushCompletedQueues(
21682166
// We don't need to check any partially completed segments because
21692167
// either they have pending task or they're complete.
21702168
) {
2171-
allComplete = true;
21722169
if (enableFloat) {
21732170
const postamble: Array<
21742171
Chunk | PrecomputedChunk,
21752172
> = (request.postamble: any);
21762173
for (let i = 0; i < postamble.length; i++) {
21772174
writeChunk(destination, postamble[i]);
21782175
}
2179-
postamble.length = 0;
21802176
}
2181-
}
2182-
completeWriting(destination);
2183-
flushBuffered(destination);
2184-
if (allComplete) {
2177+
completeWriting(destination);
2178+
flushBuffered(destination);
21852179
if (__DEV__) {
21862180
if (request.abortableTasks.size !== 0) {
21872181
console.error(
@@ -2191,6 +2185,9 @@ function flushCompletedQueues(
21912185
}
21922186
// We're done.
21932187
close(destination);
2188+
} else {
2189+
completeWriting(destination);
2190+
flushBuffered(destination);
21942191
}
21952192
}
21962193
}

0 commit comments

Comments
 (0)