Skip to content

Commit

Permalink
nits and errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gnoff committed Aug 12, 2022
1 parent 8e69ca1 commit 3d56c0e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 32 deletions.
27 changes: 3 additions & 24 deletions packages/react-dom/src/server/ReactDOMServerFormatConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,26 +243,6 @@ export function getChildFormatContext(
return parentContext;
}

function isPreambleInsertion(type: string): boolean {
switch (type) {
case 'html':
case 'head': {
return true;
}
}
return false;
}

function isPostambleInsertion(type: string): boolean {
switch (type) {
case 'body':
case 'html': {
return true;
}
}
return false;
}

export type SuspenseBoundaryID = null | PrecomputedChunk;

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

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

if (formatContext.insertionMode === ROOT_HTML_MODE) {
// If we're rendering the html tag and we're at the root (i.e. not in foreignObject)
Expand Down Expand Up @@ -1657,8 +1637,7 @@ export function pushEndInstance(
case 'body':
case 'html':
// Preamble type is nullable for feature off cases but is guaranteed when feature is on
target =
enableFloat && isPostambleInsertion(type) ? (postamble: any) : target;
target = enableFloat ? (postamble: any) : target;
// Intentional fallthrough
default: {
target.push(endTag1, stringToChunk(type), endTag2);
Expand Down
13 changes: 5 additions & 8 deletions packages/react-server/src/ReactFizzServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2081,7 +2081,6 @@ function flushCompletedQueues(
// we expect the preamble to be tiny and will ignore backpressure
writeChunk(destination, preamble[i]);
}
preamble.length = 0;
}

flushSegment(request, destination, completedRootSegment);
Expand Down Expand Up @@ -2159,7 +2158,6 @@ function flushCompletedQueues(
}
largeBoundaries.splice(0, i);
} finally {
let allComplete = false;
if (
request.allPendingTasks === 0 &&
request.pingedTasks.length === 0 &&
Expand All @@ -2168,20 +2166,16 @@ function flushCompletedQueues(
// We don't need to check any partially completed segments because
// either they have pending task or they're complete.
) {
allComplete = true;
if (enableFloat) {
const postamble: Array<
Chunk | PrecomputedChunk,
> = (request.postamble: any);
for (let i = 0; i < postamble.length; i++) {
writeChunk(destination, postamble[i]);
}
postamble.length = 0;
}
}
completeWriting(destination);
flushBuffered(destination);
if (allComplete) {
completeWriting(destination);
flushBuffered(destination);
if (__DEV__) {
if (request.abortableTasks.size !== 0) {
console.error(
Expand All @@ -2191,6 +2185,9 @@ function flushCompletedQueues(
}
// We're done.
close(destination);
} else {
completeWriting(destination);
flushBuffered(destination);
}
}
}
Expand Down

0 comments on commit 3d56c0e

Please sign in to comment.