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..2ee581f850689 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFloat-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMFloat-test.js @@ -3686,6 +3686,91 @@ body { ); }); + it('should handle referrerPolicy on image preload', async () => { + function App({isClient}) { + ReactDOM.preload('/server', { + as: 'image', + imageSrcSet: '/server', + imageSizes: '100vw', + referrerPolicy: 'no-referrer', + }); + + if (isClient) { + ReactDOM.preload('/client', { + as: 'image', + imageSrcSet: '/client', + imageSizes: '100vw', + referrerPolicy: 'no-referrer', + }); + } + + return ( + + hello + + ); + } + + await act(() => { + renderToPipeableStream().pipe(writable); + }); + expect(getMeaningfulChildren(document)).toEqual( + + + + + hello + , + ); + + const root = ReactDOMClient.hydrateRoot(document, ); + await waitForAll([]); + expect(getMeaningfulChildren(document)).toEqual( + + + + + hello + , + ); + + root.render(); + await waitForAll([]); + expect(getMeaningfulChildren(document)).toEqual( + + + + + + hello + , + ); + }); + describe('ReactDOM.prefetchDNS(href)', () => { it('creates a dns-prefetch resource when called', async () => { function App({url}) { diff --git a/packages/react-dom/src/shared/ReactDOMTypes.js b/packages/react-dom/src/shared/ReactDOMTypes.js index 7c6e9a49ff518..1ff0360617b87 100644 --- a/packages/react-dom/src/shared/ReactDOMTypes.js +++ b/packages/react-dom/src/shared/ReactDOMTypes.js @@ -18,6 +18,7 @@ export type PreloadOptions = { fetchPriority?: 'high' | 'low' | 'auto', imageSrcSet?: string, imageSizes?: string, + referrerPolicy?: string, }; export type PreinitOptions = { as: string,