File tree 5 files changed +55
-4
lines changed
test/e2e/app-dir/next-script
5 files changed +55
-4
lines changed Original file line number Diff line number Diff line change @@ -349,8 +349,13 @@ function Script(props: ScriptProps): JSX.Element | null {
349
349
ReactDOM . preload (
350
350
src ,
351
351
restProps . integrity
352
- ? { as : 'script' , integrity : restProps . integrity , nonce }
353
- : { as : 'script' , nonce }
352
+ ? {
353
+ as : 'script' ,
354
+ integrity : restProps . integrity ,
355
+ nonce,
356
+ crossOrigin : restProps . crossOrigin ,
357
+ }
358
+ : { as : 'script' , nonce, crossOrigin : restProps . crossOrigin }
354
359
)
355
360
return (
356
361
< script
@@ -370,8 +375,13 @@ function Script(props: ScriptProps): JSX.Element | null {
370
375
ReactDOM . preload (
371
376
src ,
372
377
restProps . integrity
373
- ? { as : 'script' , integrity : restProps . integrity , nonce }
374
- : { as : 'script' , nonce }
378
+ ? {
379
+ as : 'script' ,
380
+ integrity : restProps . integrity ,
381
+ nonce,
382
+ crossOrigin : restProps . crossOrigin ,
383
+ }
384
+ : { as : 'script' , nonce, crossOrigin : restProps . crossOrigin }
375
385
)
376
386
}
377
387
}
Original file line number Diff line number Diff line change
1
+ import { ReactNode } from 'react'
2
+ export default function Root ( { children } : { children : ReactNode } ) {
3
+ return (
4
+ < html >
5
+ < body > { children } </ body >
6
+ </ html >
7
+ )
8
+ }
Original file line number Diff line number Diff line change
1
+ import Script from 'next/script'
2
+
3
+ export default function Page ( ) {
4
+ return (
5
+ < Script
6
+ src = "https://code.jquery.com/jquery-3.7.1.min.js"
7
+ crossOrigin = "use-credentials"
8
+ />
9
+ )
10
+ }
Original file line number Diff line number Diff line change
1
+ import { nextTestSetup } from 'e2e-utils'
2
+
3
+ describe ( 'Script component with crossOrigin props' , ( ) => {
4
+ const { next } = nextTestSetup ( {
5
+ files : __dirname ,
6
+ } )
7
+
8
+ it ( 'should be set crossOrigin also in preload link tag' , async ( ) => {
9
+ const browser = await next . browser ( '/' )
10
+
11
+ const crossorigin = await browser
12
+ . elementByCss ( 'link[href="https://code.jquery.com/jquery-3.7.1.min.js"]' )
13
+ . getAttribute ( 'crossorigin' )
14
+
15
+ expect ( crossorigin ) . toBe ( 'use-credentials' )
16
+ } )
17
+ } )
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @type {import('next').NextConfig }
3
+ */
4
+ const nextConfig = { }
5
+
6
+ module . exports = nextConfig
You can’t perform that action at this time.
0 commit comments