diff --git a/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js b/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js index 872fda4eeb35c..214b13a64f4ca 100644 --- a/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js +++ b/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js @@ -163,14 +163,8 @@ const startInlineScript = stringToPrecomputedChunk(''); const startScriptSrc = stringToPrecomputedChunk(''); @@ -255,17 +249,15 @@ export function createResponseState( typeof scriptConfig === 'string' ? scriptConfig : scriptConfig.src; const integrity = typeof scriptConfig === 'string' ? undefined : scriptConfig.integrity; - if (nonce === undefined) { - bootstrapChunks.push( - startScriptSrc, - stringToChunk(escapeTextForBrowser(src)), - ); - } else { + + bootstrapChunks.push( + startScriptSrc, + stringToChunk(escapeTextForBrowser(src)), + ); + if (nonce) { bootstrapChunks.push( - startScriptSrcWithNonce, + scriptNonce, stringToChunk(escapeTextForBrowser(nonce)), - middleScriptSrcWithNonce, - stringToChunk(escapeTextForBrowser(src)), ); } if (integrity) { @@ -284,17 +276,16 @@ export function createResponseState( typeof scriptConfig === 'string' ? scriptConfig : scriptConfig.src; const integrity = typeof scriptConfig === 'string' ? undefined : scriptConfig.integrity; - if (nonce === undefined) { - bootstrapChunks.push( - startModuleSrc, - stringToChunk(escapeTextForBrowser(src)), - ); - } else { + + bootstrapChunks.push( + startModuleSrc, + stringToChunk(escapeTextForBrowser(src)), + ); + + if (nonce) { bootstrapChunks.push( - startModuleSrcWithNonce, + scriptNonce, stringToChunk(escapeTextForBrowser(nonce)), - middleModuleSrcWithNonce, - stringToChunk(escapeTextForBrowser(src)), ); } if (integrity) { diff --git a/packages/react-dom/src/__tests__/ReactDOMFizzServerBrowser-test.js b/packages/react-dom/src/__tests__/ReactDOMFizzServerBrowser-test.js index 9caa09a6739ba..c6dbae0d0c403 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFizzServerBrowser-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMFizzServerBrowser-test.js @@ -500,7 +500,7 @@ describe('ReactDOMFizzServerBrowser', () => { ); const result = await readResult(stream); expect(result).toMatchInlineSnapshot( - `"
hello world
"`, + `"
hello world
"`, ); }); });