From a7bf5ba614c6ddbd1eb3057c71f72efd1b6c21a9 Mon Sep 17 00:00:00 2001
From: Josh Story
Date: Tue, 13 Jun 2023 13:59:45 -0700
Subject: [PATCH] [Float][Fizz] add crossOrigin support for preloading
bootstrap scripts and bootstrap modules (#26942)
The recently merged support for crossorigin in bootstrap scripts did not
implement the functionality for preloading. This adds it
see #26844
---
.../src/server/ReactFizzConfigDOM.js | 8 ++++++--
.../src/__tests__/ReactDOMFizzServer-test.js | 14 +++++++++++++-
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js b/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
index fa029c17da0a9..0294e57e46ebe 100644
--- a/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
+++ b/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
@@ -281,7 +281,7 @@ export function createResponseState(
? 'use-credentials'
: '';
- preloadBootstrapScript(resources, src, nonce, integrity);
+ preloadBootstrapScript(resources, src, nonce, integrity, crossOrigin);
bootstrapChunks.push(
startScriptSrc,
@@ -322,7 +322,7 @@ export function createResponseState(
? 'use-credentials'
: '';
- preloadBootstrapModule(resources, src, nonce, integrity);
+ preloadBootstrapModule(resources, src, nonce, integrity, crossOrigin);
bootstrapChunks.push(
startModuleSrc,
@@ -5425,6 +5425,7 @@ function preloadBootstrapScript(
src: string,
nonce: ?string,
integrity: ?string,
+ crossOrigin: ?string,
): void {
const key = getResourceKey('script', src);
if (__DEV__) {
@@ -5444,6 +5445,7 @@ function preloadBootstrapScript(
as: 'script',
nonce,
integrity,
+ crossOrigin,
};
const resource: PreloadResource = {
type: 'preload',
@@ -5465,6 +5467,7 @@ function preloadBootstrapModule(
src: string,
nonce: ?string,
integrity: ?string,
+ crossOrigin: ?string,
): void {
const key = getResourceKey('script', src);
if (__DEV__) {
@@ -5483,6 +5486,7 @@ function preloadBootstrapModule(
href: src,
nonce,
integrity,
+ crossOrigin,
};
const resource: PreloadResource = {
type: 'preload',
diff --git a/packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js b/packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js
index e0f6ba3226667..434924e86a039 100644
--- a/packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js
@@ -3865,7 +3865,19 @@ describe('ReactDOMFizzServer', () => {
expect(getVisibleChildren(document)).toEqual(
-
+
+
+
+
+
+
+
+
+
hello world