From 2e3854862dce2b91852d39a7b4629368c0cb5fa1 Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 11 Jul 2023 16:40:43 -0400 Subject: [PATCH] Add `referrerPolicy` option to `ReactDOM.preload()` --- .../src/client/ReactFiberConfigDOM.js | 1 + .../src/server/ReactFizzConfigDOM.js | 1 + .../src/__tests__/ReactDOMFloat-test.js | 28 +++++++++++++++++++ .../react-dom/src/shared/ReactDOMTypes.js | 1 + 4 files changed, 31 insertions(+) diff --git a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js index 94698a8d527a9..1149e442f98ea 100644 --- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js +++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js @@ -2284,6 +2284,7 @@ function preloadPropsFromPreloadOptions( fetchPriority: options.fetchPriority, imageSrcSet: options.imageSrcSet, imageSizes: options.imageSizes, + referrerPolicy: options.referrerPolicy, }; } diff --git a/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js b/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js index b6e1e90507d5b..ec7d829428731 100644 --- a/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js +++ b/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js @@ -5564,6 +5564,7 @@ function preloadPropsFromPreloadOptions( fetchPriority: options.fetchPriority, imageSrcSet: options.imageSrcSet, imageSizes: options.imageSizes, + referrerPolicy: options.referrerPolicy, }; } diff --git a/packages/react-dom/src/__tests__/ReactDOMFloat-test.js b/packages/react-dom/src/__tests__/ReactDOMFloat-test.js index 3a893c616e14a..8dc6c58318f9e 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFloat-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMFloat-test.js @@ -3585,6 +3585,13 @@ body { imageSizes: 'makes no sense', }); + ReactDOM.preload('rp', { + as: 'image', + imageSrcSet: 'rpsrcset', + imageSizes: 'rpsizes', + referrerPolicy: 'no-referrer', + }); + if (isClient) { // Will key off href in absense of imageSrcSet ReactDOM.preload('client', {as: 'image'}); @@ -3634,6 +3641,13 @@ body { imagesizes="foosizes" /> + hello , @@ -3653,6 +3667,13 @@ body { imagesizes="foosizes" /> + hello , @@ -3672,6 +3693,13 @@ body { imagesizes="foosizes" /> +