@@ -7,21 +7,28 @@ Files in the rsc directory are meant to be packaged as part of the RSC graph usi
7
7
import ReactDOM from 'react-dom'
8
8
9
9
export function preloadStyle ( href : string , crossOrigin ?: string | undefined ) {
10
- ReactDOM . preload ( href , { as : 'style' , crossOrigin } )
10
+ const opts : any = { as : 'style' }
11
+ if ( typeof crossOrigin === 'string' ) {
12
+ opts . crossOrigin = crossOrigin
13
+ }
14
+ ReactDOM . preload ( href , opts )
11
15
}
12
16
13
17
export function preloadFont (
14
18
href : string ,
15
19
type : string ,
16
20
crossOrigin ?: string | undefined
17
21
) {
18
- ; ( ReactDOM as any ) . preload ( href , { as : 'font' , type, crossOrigin } )
22
+ const opts : any = { as : 'font' , type }
23
+ if ( typeof crossOrigin === 'string' ) {
24
+ opts . crossOrigin = crossOrigin
25
+ }
26
+ ReactDOM . preload ( href , opts )
19
27
}
20
28
21
29
export function preconnect ( href : string , crossOrigin ?: string | undefined ) {
22
- if ( typeof crossOrigin === 'string' ) {
23
- ; ( ReactDOM as any ) . preconnect ( href , { crossOrigin } )
24
- } else {
25
- ; ( ReactDOM as any ) . preconnect ( href )
26
- }
30
+ ; ( ReactDOM as any ) . preconnect (
31
+ href ,
32
+ typeof crossOrigin === 'string' ? { crossOrigin } : undefined
33
+ )
27
34
}
0 commit comments