@@ -3585,13 +3585,6 @@ body {
3585
3585
imageSizes : 'makes no sense' ,
3586
3586
} ) ;
3587
3587
3588
- ReactDOM . preload ( 'rp' , {
3589
- as : 'image' ,
3590
- imageSrcSet : 'rpsrcset' ,
3591
- imageSizes : 'rpsizes' ,
3592
- referrerPolicy : 'no-referrer' ,
3593
- } ) ;
3594
-
3595
3588
if ( isClient ) {
3596
3589
// Will key off href in absense of imageSrcSet
3597
3590
ReactDOM . preload ( 'client' , { as : 'image' } ) ;
@@ -3641,19 +3634,31 @@ body {
3641
3634
imagesizes = "foosizes"
3642
3635
/>
3643
3636
< 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" />
3644
3649
< link
3645
3650
rel = "preload"
3646
3651
as = "image"
3647
- imagesrcset = "rpsrcset"
3648
- imagesizes = "rpsizes"
3649
- referrerpolicy = "no-referrer"
3652
+ imagesrcset = "fooset"
3653
+ imagesizes = "foosizes"
3650
3654
/>
3655
+ < link rel = "preload" as = "somethingelse" href = "bar" />
3651
3656
</ head >
3652
3657
< body > hello</ body >
3653
3658
</ html > ,
3654
3659
) ;
3655
3660
3656
- const root = ReactDOMClient . hydrateRoot ( document , < App /> ) ;
3661
+ root . render ( < App isClient = { true } /> ) ;
3657
3662
await waitForAll ( [ ] ) ;
3658
3663
expect ( getMeaningfulChildren ( document ) ) . toEqual (
3659
3664
< html >
@@ -3667,46 +3672,98 @@ body {
3667
3672
imagesizes = "foosizes"
3668
3673
/>
3669
3674
< 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 >
3670
3720
< link
3671
3721
rel = "preload"
3672
3722
as = "image"
3673
- imagesrcset = "rpsrcset "
3674
- imagesizes = "rpsizes "
3723
+ imagesrcset = "/server "
3724
+ imagesizes = "100vw "
3675
3725
referrerpolicy = "no-referrer"
3676
3726
/>
3677
3727
</ head >
3678
3728
< body > hello</ body >
3679
3729
</ html > ,
3680
3730
) ;
3681
3731
3682
- root . render ( < App isClient = { true } /> ) ;
3732
+ const root = ReactDOMClient . hydrateRoot ( document , < App /> ) ;
3683
3733
await waitForAll ( [ ] ) ;
3684
3734
expect ( getMeaningfulChildren ( document ) ) . toEqual (
3685
3735
< html >
3686
3736
< head >
3687
- < link rel = "preload" as = "image" href = "foo" />
3688
- < link rel = "preload" as = "image" imagesrcset = "fooset" />
3689
3737
< link
3690
3738
rel = "preload"
3691
3739
as = "image"
3692
- imagesrcset = "fooset"
3693
- imagesizes = "foosizes"
3740
+ imagesrcset = "/server"
3741
+ imagesizes = "100vw"
3742
+ referrerpolicy = "no-referrer"
3694
3743
/>
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 >
3696
3754
< link
3697
3755
rel = "preload"
3698
3756
as = "image"
3699
- imagesrcset = "rpsrcset "
3700
- imagesizes = "rpsizes "
3757
+ imagesrcset = "/server "
3758
+ imagesizes = "100vw "
3701
3759
referrerpolicy = "no-referrer"
3702
3760
/>
3703
- < link rel = "preload" as = "image" href = "client" />
3704
- < link rel = "preload" as = "image" imagesrcset = "clientset" />
3705
3761
< link
3706
3762
rel = "preload"
3707
3763
as = "image"
3708
- imagesrcset = "clientset"
3709
- imagesizes = "clientsizes"
3764
+ imagesrcset = "/client"
3765
+ imagesizes = "100vw"
3766
+ referrerpolicy = "no-referrer"
3710
3767
/>
3711
3768
</ head >
3712
3769
< body > hello</ body >
0 commit comments