From 683a714bc1e27e7e569580c62af4214ea78dc19e Mon Sep 17 00:00:00 2001 From: Josh Story Date: Wed, 31 May 2023 11:19:18 -0700 Subject: [PATCH] preinitialized stylesheets did not render the integrity option on the client implementation of Float. This was an oversight. --- .../src/client/ReactFiberConfigDOM.js | 1 + .../src/__tests__/ReactDOMFloat-test.js | 65 +++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js index f3441a3557e37..62afafe11efcf 100644 --- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js +++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js @@ -2394,6 +2394,7 @@ function stylesheetPropsFromPreinitOptions( href, 'data-precedence': precedence, crossOrigin: options.crossOrigin, + integrity: options.integrity, }; } diff --git a/packages/react-dom/src/__tests__/ReactDOMFloat-test.js b/packages/react-dom/src/__tests__/ReactDOMFloat-test.js index 842b9c4153e2c..b0303165d0dba 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFloat-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMFloat-test.js @@ -4409,6 +4409,71 @@ body { , ); }); + + it('accepts an `integrity` option for `as: "style"`', async () => { + function Component({src, hash}) { + ReactDOM.preinit(src, {as: 'style', integrity: hash}); + return 'hello'; + } + + await act(() => { + renderToPipeableStream( + + + + + , + { + nonce: 'R4nD0m', + }, + ).pipe(writable); + }); + + expect(getMeaningfulChildren(document)).toEqual( + + + + + hello + , + ); + + await clientAct(() => { + ReactDOMClient.hydrateRoot( + document, + + + + + , + ); + }); + + expect(getMeaningfulChildren(document)).toEqual( + + + + + + hello + , + ); + }); }); describe('Stylesheet Resources', () => {