[Float] Nonce preload support (#26939)

Some browsers, with some CSP configuration, will not preload a script if
the prelaod link tag does not provide a valid nonce attribute. This
change adds the ability to specify a nonce for `ReactDOM.preload(..., {
as: "script" })`

DiffTrain build for [86acc10f25](https://github.com/facebook/react/commit/86acc10f2596e1a6fe2fd57a5b325de85175800b)
This commit is contained in:
gnoff
2023-06-15 20:46:42 +00:00
parent 1d94a43c45
commit b437e4d88b
21 changed files with 48 additions and 32 deletions
+1 -1
View File
@@ -1 +1 @@
a7bf5ba614c6ddbd1eb3057c71f72efd1b6c21a9
86acc10f2596e1a6fe2fd57a5b325de85175800b
+1 -1
View File
@@ -27,7 +27,7 @@ if (
}
"use strict";
var ReactVersion = "18.3.0-www-modern-180bd813";
var ReactVersion = "18.3.0-www-modern-5fb44b73";
// ATTENTION
// When adding new symbols to this file,
+1 -1
View File
@@ -69,7 +69,7 @@ function _assertThisInitialized(self) {
return self;
}
var ReactVersion = "18.3.0-www-modern-0a8a0f8c";
var ReactVersion = "18.3.0-www-modern-520e6c62";
var LegacyRoot = 0;
var ConcurrentRoot = 1;
@@ -9858,7 +9858,7 @@ var slice = Array.prototype.slice,
return null;
},
bundleType: 0,
version: "18.3.0-www-modern-27da91db",
version: "18.3.0-www-modern-e8821afc",
rendererPackageName: "react-art"
};
var internals$jscomp$inline_1298 = {
@@ -9889,7 +9889,7 @@ var internals$jscomp$inline_1298 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-www-modern-27da91db"
reconcilerVersion: "18.3.0-www-modern-e8821afc"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1299 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -34178,7 +34178,7 @@ function createFiberRoot(
return root;
}
var ReactVersion = "18.3.0-www-classic-202be78c";
var ReactVersion = "18.3.0-www-classic-3dccae4a";
function createPortal$1(
children,
@@ -43823,6 +43823,7 @@ function preloadPropsFromPreloadOptions(href, as, options) {
crossOrigin: as === "font" ? "" : options.crossOrigin,
integrity: options.integrity,
type: options.type,
nonce: options.nonce,
fetchPriority: options.fetchPriority
};
}
+2 -1
View File
@@ -34023,7 +34023,7 @@ function createFiberRoot(
return root;
}
var ReactVersion = "18.3.0-www-modern-0a8a0f8c";
var ReactVersion = "18.3.0-www-modern-520e6c62";
function createPortal$1(
children,
@@ -44333,6 +44333,7 @@ function preloadPropsFromPreloadOptions(href, as, options) {
crossOrigin: as === "font" ? "" : options.crossOrigin,
integrity: options.integrity,
type: options.type,
nonce: options.nonce,
fetchPriority: options.fetchPriority
};
}
@@ -15303,6 +15303,7 @@ function preload$1(href, options) {
crossOrigin: "font" === as ? "" : options.crossOrigin,
integrity: options.integrity,
type: options.type,
nonce: options.nonce,
fetchPriority: options.fetchPriority
}),
preloadPropsMap.set(key, href),
@@ -16643,7 +16644,7 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1815 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "18.3.0-www-classic-a78c92e7",
version: "18.3.0-www-classic-c1034a44",
rendererPackageName: "react-dom"
};
var internals$jscomp$inline_2184 = {
@@ -16673,7 +16674,7 @@ var internals$jscomp$inline_2184 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-www-classic-a78c92e7"
reconcilerVersion: "18.3.0-www-classic-c1034a44"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2185 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -16916,4 +16917,4 @@ exports.unstable_renderSubtreeIntoContainer = function (
);
};
exports.unstable_runWithPriority = runWithPriority;
exports.version = "18.3.0-www-classic-a78c92e7";
exports.version = "18.3.0-www-classic-c1034a44";
@@ -15533,6 +15533,7 @@ function preload$1(href, options) {
crossOrigin: "font" === as ? "" : options.crossOrigin,
integrity: options.integrity,
type: options.type,
nonce: options.nonce,
fetchPriority: options.fetchPriority
}),
preloadPropsMap.set(key, href),
@@ -16172,7 +16173,7 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1774 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "18.3.0-www-modern-27da91db",
version: "18.3.0-www-modern-e8821afc",
rendererPackageName: "react-dom"
};
var internals$jscomp$inline_2148 = {
@@ -16203,7 +16204,7 @@ var internals$jscomp$inline_2148 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-www-modern-27da91db"
reconcilerVersion: "18.3.0-www-modern-e8821afc"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2149 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -16374,4 +16375,4 @@ exports.unstable_createEventHandle = function (type, options) {
return eventHandle;
};
exports.unstable_runWithPriority = runWithPriority;
exports.version = "18.3.0-www-modern-27da91db";
exports.version = "18.3.0-www-modern-e8821afc";
@@ -16078,6 +16078,7 @@ function preload$1(href, options) {
crossOrigin: "font" === as ? "" : options.crossOrigin,
integrity: options.integrity,
type: options.type,
nonce: options.nonce,
fetchPriority: options.fetchPriority
}),
preloadPropsMap.set(key, href),
@@ -17418,7 +17419,7 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1900 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "18.3.0-www-classic-6cc31d50",
version: "18.3.0-www-classic-1233fa25",
rendererPackageName: "react-dom"
};
(function (internals) {
@@ -17462,7 +17463,7 @@ var devToolsConfig$jscomp$inline_1900 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-www-classic-6cc31d50"
reconcilerVersion: "18.3.0-www-classic-1233fa25"
});
assign(Internals, {
ReactBrowserEventEmitter: {
@@ -17692,7 +17693,7 @@ exports.unstable_renderSubtreeIntoContainer = function (
);
};
exports.unstable_runWithPriority = runWithPriority;
exports.version = "18.3.0-www-classic-6cc31d50";
exports.version = "18.3.0-www-classic-1233fa25";
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
@@ -16302,6 +16302,7 @@ function preload$1(href, options) {
crossOrigin: "font" === as ? "" : options.crossOrigin,
integrity: options.integrity,
type: options.type,
nonce: options.nonce,
fetchPriority: options.fetchPriority
}),
preloadPropsMap.set(key, href),
@@ -16941,7 +16942,7 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1859 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "18.3.0-www-modern-2704a18e",
version: "18.3.0-www-modern-d08e2742",
rendererPackageName: "react-dom"
};
(function (internals) {
@@ -16986,7 +16987,7 @@ var devToolsConfig$jscomp$inline_1859 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-www-modern-2704a18e"
reconcilerVersion: "18.3.0-www-modern-d08e2742"
});
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals;
exports.createPortal = function (children, container) {
@@ -17144,7 +17145,7 @@ exports.unstable_createEventHandle = function (type, options) {
return eventHandle;
};
exports.unstable_runWithPriority = runWithPriority;
exports.version = "18.3.0-www-modern-2704a18e";
exports.version = "18.3.0-www-modern-d08e2742";
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
@@ -19,7 +19,7 @@ if (__DEV__) {
var React = require("react");
var ReactDOM = require("react-dom");
var ReactVersion = "18.3.0-www-classic-22ab72ab";
var ReactVersion = "18.3.0-www-classic-4d7a4acb";
// This refers to a WWW module.
var warningWWW = require("warning");
@@ -7521,6 +7521,7 @@ function preloadPropsFromPreloadOptions(href, as, options) {
crossOrigin: as === "font" ? "" : options.crossOrigin,
integrity: options.integrity,
type: options.type,
nonce: options.nonce,
fetchPriority: options.fetchPriority
};
}
@@ -19,7 +19,7 @@ if (__DEV__) {
var React = require("react");
var ReactDOM = require("react-dom");
var ReactVersion = "18.3.0-www-modern-27b3679a";
var ReactVersion = "18.3.0-www-modern-18f0b486";
// This refers to a WWW module.
var warningWWW = require("warning");
@@ -7521,6 +7521,7 @@ function preloadPropsFromPreloadOptions(href, as, options) {
crossOrigin: as === "font" ? "" : options.crossOrigin,
integrity: options.integrity,
type: options.type,
nonce: options.nonce,
fetchPriority: options.fetchPriority
};
}
@@ -1855,6 +1855,7 @@ function preload(href, options) {
crossOrigin: "font" === as ? "" : options.crossOrigin,
integrity: options.integrity,
type: options.type,
nonce: options.nonce,
fetchPriority: options.fetchPriority
}
}),
@@ -4001,4 +4002,4 @@ exports.renderToString = function (children, options) {
'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server'
);
};
exports.version = "18.3.0-www-classic-43b0ed5e";
exports.version = "18.3.0-www-classic-99c1dfc7";
@@ -1854,6 +1854,7 @@ function preload(href, options) {
crossOrigin: "font" === as ? "" : options.crossOrigin,
integrity: options.integrity,
type: options.type,
nonce: options.nonce,
fetchPriority: options.fetchPriority
}
}),
@@ -3899,4 +3900,4 @@ exports.renderToString = function (children, options) {
'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server'
);
};
exports.version = "18.3.0-www-modern-0fa0d6a8";
exports.version = "18.3.0-www-modern-7d85fe51";
@@ -7528,6 +7528,7 @@ function preloadPropsFromPreloadOptions(href, as, options) {
crossOrigin: as === "font" ? "" : options.crossOrigin,
integrity: options.integrity,
type: options.type,
nonce: options.nonce,
fetchPriority: options.fetchPriority
};
}
@@ -1904,6 +1904,7 @@ function preload(href, options) {
crossOrigin: "font" === as ? "" : options.crossOrigin,
integrity: options.integrity,
type: options.type,
nonce: options.nonce,
fetchPriority: options.fetchPriority
}
}),
@@ -34795,7 +34795,7 @@ function createFiberRoot(
return root;
}
var ReactVersion = "18.3.0-www-classic-a43be0aa";
var ReactVersion = "18.3.0-www-classic-4a9fda08";
function createPortal$1(
children,
@@ -44572,6 +44572,7 @@ function preloadPropsFromPreloadOptions(href, as, options) {
crossOrigin: as === "font" ? "" : options.crossOrigin,
integrity: options.integrity,
type: options.type,
nonce: options.nonce,
fetchPriority: options.fetchPriority
};
}
@@ -34640,7 +34640,7 @@ function createFiberRoot(
return root;
}
var ReactVersion = "18.3.0-www-modern-dd1ac991";
var ReactVersion = "18.3.0-www-modern-6dec7344";
function createPortal$1(
children,
@@ -45082,6 +45082,7 @@ function preloadPropsFromPreloadOptions(href, as, options) {
crossOrigin: as === "font" ? "" : options.crossOrigin,
integrity: options.integrity,
type: options.type,
nonce: options.nonce,
fetchPriority: options.fetchPriority
};
}
@@ -15632,6 +15632,7 @@ function preload$1(href, options) {
crossOrigin: "font" === as ? "" : options.crossOrigin,
integrity: options.integrity,
type: options.type,
nonce: options.nonce,
fetchPriority: options.fetchPriority
}),
preloadPropsMap.set(key, href),
@@ -16972,7 +16973,7 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1844 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "18.3.0-www-classic-2d5fcb75",
version: "18.3.0-www-classic-1f937379",
rendererPackageName: "react-dom"
};
var internals$jscomp$inline_2218 = {
@@ -17002,7 +17003,7 @@ var internals$jscomp$inline_2218 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-www-classic-2d5fcb75"
reconcilerVersion: "18.3.0-www-classic-1f937379"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2219 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -17396,4 +17397,4 @@ exports.unstable_renderSubtreeIntoContainer = function (
);
};
exports.unstable_runWithPriority = runWithPriority;
exports.version = "18.3.0-www-classic-2d5fcb75";
exports.version = "18.3.0-www-classic-1f937379";
@@ -15917,6 +15917,7 @@ function preload$1(href, options) {
crossOrigin: "font" === as ? "" : options.crossOrigin,
integrity: options.integrity,
type: options.type,
nonce: options.nonce,
fetchPriority: options.fetchPriority
}),
preloadPropsMap.set(key, href),
@@ -16556,7 +16557,7 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1803 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "18.3.0-www-modern-180bd813",
version: "18.3.0-www-modern-5fb44b73",
rendererPackageName: "react-dom"
};
var internals$jscomp$inline_2182 = {
@@ -16587,7 +16588,7 @@ var internals$jscomp$inline_2182 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-www-modern-180bd813"
reconcilerVersion: "18.3.0-www-modern-5fb44b73"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2183 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -16909,4 +16910,4 @@ exports.unstable_createEventHandle = function (type, options) {
return eventHandle;
};
exports.unstable_runWithPriority = runWithPriority;
exports.version = "18.3.0-www-modern-180bd813";
exports.version = "18.3.0-www-modern-5fb44b73";
@@ -24553,7 +24553,7 @@ function createFiberRoot(
return root;
}
var ReactVersion = "18.3.0-www-classic-a43be0aa";
var ReactVersion = "18.3.0-www-classic-4a9fda08";
// Might add PROFILE later.