@@ -3585,13 +3585,6 @@ body {
35853585 imageSizes : 'makes no sense' ,
35863586 } ) ;
35873587
3588- ReactDOM . preload ( 'rp' , {
3589- as : 'image' ,
3590- imageSrcSet : 'rpsrcset' ,
3591- imageSizes : 'rpsizes' ,
3592- referrerPolicy : 'no-referrer' ,
3593- } ) ;
3594-
35953588 if ( isClient ) {
35963589 // Will key off href in absense of imageSrcSet
35973590 ReactDOM . preload ( 'client' , { as : 'image' } ) ;
@@ -3641,19 +3634,31 @@ body {
36413634 imagesizes = "foosizes"
36423635 />
36433636 < link rel = "preload" as = "somethingelse" href = "bar" />
3637+ </ head >
3638+ < body > hello</ body >
3639+ </ html > ,
3640+ ) ;
3641+
3642+ const root = ReactDOMClient . hydrateRoot ( document , < App /> ) ;
3643+ await waitForAll ( [ ] ) ;
3644+ expect ( getMeaningfulChildren ( document ) ) . toEqual (
3645+ < html >
3646+ < head >
3647+ < link rel = "preload" as = "image" href = "foo" />
3648+ < link rel = "preload" as = "image" imagesrcset = "fooset" />
36443649 < link
36453650 rel = "preload"
36463651 as = "image"
3647- imagesrcset = "rpsrcset"
3648- imagesizes = "rpsizes"
3649- referrerpolicy = "no-referrer"
3652+ imagesrcset = "fooset"
3653+ imagesizes = "foosizes"
36503654 />
3655+ < link rel = "preload" as = "somethingelse" href = "bar" />
36513656 </ head >
36523657 < body > hello</ body >
36533658 </ html > ,
36543659 ) ;
36553660
3656- const root = ReactDOMClient . hydrateRoot ( document , < App /> ) ;
3661+ root . render ( < App isClient = { true } /> ) ;
36573662 await waitForAll ( [ ] ) ;
36583663 expect ( getMeaningfulChildren ( document ) ) . toEqual (
36593664 < html >
@@ -3667,46 +3672,98 @@ body {
36673672 imagesizes = "foosizes"
36683673 />
36693674 < link rel = "preload" as = "somethingelse" href = "bar" />
3675+ < link rel = "preload" as = "image" href = "client" />
3676+ < link rel = "preload" as = "image" imagesrcset = "clientset" />
3677+ < link
3678+ rel = "preload"
3679+ as = "image"
3680+ imagesrcset = "clientset"
3681+ imagesizes = "clientsizes"
3682+ />
3683+ </ head >
3684+ < body > hello</ body >
3685+ </ html > ,
3686+ ) ;
3687+ } ) ;
3688+
3689+ it ( 'should handle referrerPolicy on image preload' , async ( ) => {
3690+ function App ( { isClient} ) {
3691+ ReactDOM . preload ( '/server' , {
3692+ as : 'image' ,
3693+ imageSrcSet : '/server' ,
3694+ imageSizes : '100vw' ,
3695+ referrerPolicy : 'no-referrer' ,
3696+ } ) ;
3697+
3698+ if ( isClient ) {
3699+ ReactDOM . preload ( '/client' , {
3700+ as : 'image' ,
3701+ imageSrcSet : '/client' ,
3702+ imageSizes : '100vw' ,
3703+ referrerPolicy : 'no-referrer' ,
3704+ } ) ;
3705+ }
3706+
3707+ return (
3708+ < html >
3709+ < body > hello</ body >
3710+ </ html >
3711+ ) ;
3712+ }
3713+
3714+ await act ( ( ) => {
3715+ renderToPipeableStream ( < App /> ) . pipe ( writable ) ;
3716+ } ) ;
3717+ expect ( getMeaningfulChildren ( document ) ) . toEqual (
3718+ < html >
3719+ < head >
36703720 < link
36713721 rel = "preload"
36723722 as = "image"
3673- imagesrcset = "rpsrcset "
3674- imagesizes = "rpsizes "
3723+ imagesrcset = "/server "
3724+ imagesizes = "100vw "
36753725 referrerpolicy = "no-referrer"
36763726 />
36773727 </ head >
36783728 < body > hello</ body >
36793729 </ html > ,
36803730 ) ;
36813731
3682- root . render ( < App isClient = { true } /> ) ;
3732+ const root = ReactDOMClient . hydrateRoot ( document , < App /> ) ;
36833733 await waitForAll ( [ ] ) ;
36843734 expect ( getMeaningfulChildren ( document ) ) . toEqual (
36853735 < html >
36863736 < head >
3687- < link rel = "preload" as = "image" href = "foo" />
3688- < link rel = "preload" as = "image" imagesrcset = "fooset" />
36893737 < link
36903738 rel = "preload"
36913739 as = "image"
3692- imagesrcset = "fooset"
3693- imagesizes = "foosizes"
3740+ imagesrcset = "/server"
3741+ imagesizes = "100vw"
3742+ referrerpolicy = "no-referrer"
36943743 />
3695- < link rel = "preload" as = "somethingelse" href = "bar" />
3744+ </ head >
3745+ < body > hello</ body >
3746+ </ html > ,
3747+ ) ;
3748+
3749+ root . render ( < App isClient = { true } /> ) ;
3750+ await waitForAll ( [ ] ) ;
3751+ expect ( getMeaningfulChildren ( document ) ) . toEqual (
3752+ < html >
3753+ < head >
36963754 < link
36973755 rel = "preload"
36983756 as = "image"
3699- imagesrcset = "rpsrcset "
3700- imagesizes = "rpsizes "
3757+ imagesrcset = "/server "
3758+ imagesizes = "100vw "
37013759 referrerpolicy = "no-referrer"
37023760 />
3703- < link rel = "preload" as = "image" href = "client" />
3704- < link rel = "preload" as = "image" imagesrcset = "clientset" />
37053761 < link
37063762 rel = "preload"
37073763 as = "image"
3708- imagesrcset = "clientset"
3709- imagesizes = "clientsizes"
3764+ imagesrcset = "/client"
3765+ imagesizes = "100vw"
3766+ referrerpolicy = "no-referrer"
37103767 />
37113768 </ head >
37123769 < body > hello</ body >
0 commit comments