Update preload links to support nonce and fetchpriority (#26826)

Currently when React generates rel=preload link tags for script/stylesheet resources, it will not carryover nonce and fetchpriority values if specified on the original elements.

This change ensures that the preload links use the nonce and fetchPriority values if they were specified.

DiffTrain build for [535c038d15](https://github.com/facebook/react/commit/535c038d15d21f33e678187410d658456cc0ce39)
This commit is contained in:
gnoff
2023-05-23 03:01:14 +00:00
parent e48bfabe44
commit 1d665b6fa3
7 changed files with 23 additions and 5 deletions
+1 -1
View File
@@ -1 +1 @@
5309f102854475030fb91ab732141411b49c1126
535c038d15d21f33e678187410d658456cc0ce39
@@ -19,7 +19,7 @@ if (__DEV__) {
var React = require("react");
var ReactDOM = require("react-dom");
var ReactVersion = "18.3.0-www-classic-6fc3b80a";
var ReactVersion = "18.3.0-www-classic-4ad4dc38";
// This refers to a WWW module.
var warningWWW = require("warning");
@@ -7504,6 +7504,7 @@ function preloadAsStylePropsFromProps(href, props) {
as: "style",
href: href,
crossOrigin: props.crossOrigin,
fetchPriority: props.fetchPriority,
integrity: props.integrity,
media: props.media,
hrefLang: props.hrefLang,
@@ -7517,7 +7518,9 @@ function preloadAsScriptPropsFromProps(href, props) {
as: "script",
href: href,
crossOrigin: props.crossOrigin,
fetchPriority: props.fetchPriority,
integrity: props.integrity,
nonce: props.nonce,
referrerPolicy: props.referrerPolicy
};
}
@@ -19,7 +19,7 @@ if (__DEV__) {
var React = require("react");
var ReactDOM = require("react-dom");
var ReactVersion = "18.3.0-www-modern-044bfa2a";
var ReactVersion = "18.3.0-www-modern-bcd77572";
// This refers to a WWW module.
var warningWWW = require("warning");
@@ -7504,6 +7504,7 @@ function preloadAsStylePropsFromProps(href, props) {
as: "style",
href: href,
crossOrigin: props.crossOrigin,
fetchPriority: props.fetchPriority,
integrity: props.integrity,
media: props.media,
hrefLang: props.hrefLang,
@@ -7517,7 +7518,9 @@ function preloadAsScriptPropsFromProps(href, props) {
as: "script",
href: href,
crossOrigin: props.crossOrigin,
fetchPriority: props.fetchPriority,
integrity: props.integrity,
nonce: props.nonce,
referrerPolicy: props.referrerPolicy
};
}
@@ -1085,7 +1085,9 @@ function pushStartInstance(
as: "script",
href: props.src,
crossOrigin: props.crossOrigin,
fetchPriority: props.fetchPriority,
integrity: props.integrity,
nonce: props.nonce,
referrerPolicy: props.referrerPolicy
}
}),
@@ -2104,6 +2106,7 @@ function preloadAsStylePropsFromProps(href, props) {
as: "style",
href: href,
crossOrigin: props.crossOrigin,
fetchPriority: props.fetchPriority,
integrity: props.integrity,
media: props.media,
hrefLang: props.hrefLang,
@@ -4011,4 +4014,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-cf2c1840";
exports.version = "18.3.0-www-classic-15c0e05f";
@@ -1084,7 +1084,9 @@ function pushStartInstance(
as: "script",
href: props.src,
crossOrigin: props.crossOrigin,
fetchPriority: props.fetchPriority,
integrity: props.integrity,
nonce: props.nonce,
referrerPolicy: props.referrerPolicy
}
}),
@@ -2103,6 +2105,7 @@ function preloadAsStylePropsFromProps(href, props) {
as: "style",
href: href,
crossOrigin: props.crossOrigin,
fetchPriority: props.fetchPriority,
integrity: props.integrity,
media: props.media,
hrefLang: props.hrefLang,
@@ -3909,4 +3912,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-c8d57b01";
exports.version = "18.3.0-www-modern-38ef6896";
@@ -7511,6 +7511,7 @@ function preloadAsStylePropsFromProps(href, props) {
as: "style",
href: href,
crossOrigin: props.crossOrigin,
fetchPriority: props.fetchPriority,
integrity: props.integrity,
media: props.media,
hrefLang: props.hrefLang,
@@ -7524,7 +7525,9 @@ function preloadAsScriptPropsFromProps(href, props) {
as: "script",
href: href,
crossOrigin: props.crossOrigin,
fetchPriority: props.fetchPriority,
integrity: props.integrity,
nonce: props.nonce,
referrerPolicy: props.referrerPolicy
};
}
@@ -1106,7 +1106,9 @@ function pushStartInstance(
as: "script",
href: props.src,
crossOrigin: props.crossOrigin,
fetchPriority: props.fetchPriority,
integrity: props.integrity,
nonce: props.nonce,
referrerPolicy: props.referrerPolicy
}
}),
@@ -2158,6 +2160,7 @@ function preloadAsStylePropsFromProps(href, props) {
as: "style",
href: href,
crossOrigin: props.crossOrigin,
fetchPriority: props.fetchPriority,
integrity: props.integrity,
media: props.media,
hrefLang: props.hrefLang,