File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
packages/react-dom/src/__tests__ Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -6290,6 +6290,45 @@ body {
62906290 ' in App (at **)' ,
62916291 ] ) ;
62926292 } ) ;
6293+
6294+ it ( 'supports nonce' , async ( ) => {
6295+ function App ( { url} ) {
6296+ ReactDOM . preloadModule ( url , { as : 'script' , nonce : 'abc' } ) ;
6297+ return 'hello' ;
6298+ }
6299+
6300+ await act ( ( ) => {
6301+ renderToPipeableStream ( < App url = "server" /> ) . pipe ( writable ) ;
6302+ } ) ;
6303+
6304+ expect ( getMeaningfulChildren ( document ) ) . toEqual (
6305+ < html >
6306+ < head />
6307+ < body >
6308+ < div id = "container" >
6309+ < link rel = "modulepreload" href = "server" nonce = "abc" />
6310+ hello
6311+ </ div >
6312+ </ body >
6313+ </ html > ,
6314+ ) ;
6315+
6316+ ReactDOMClient . hydrateRoot ( container , < App url = "client" /> ) ;
6317+ await waitForAll ( [ ] ) ;
6318+ expect ( getMeaningfulChildren ( document ) ) . toEqual (
6319+ < html >
6320+ < head >
6321+ < link rel = "modulepreload" href = "client" nonce = "abc" />
6322+ </ head >
6323+ < body >
6324+ < div id = "container" >
6325+ < link rel = "modulepreload" href = "server" nonce = "abc" />
6326+ hello
6327+ </ div >
6328+ </ body >
6329+ </ html > ,
6330+ ) ;
6331+ } ) ;
62936332 } ) ;
62946333
62956334 describe ( 'ReactDOM.preinit(href, { as: ... })' , ( ) => {
You can’t perform that action at this time.
0 commit comments