File tree 6 files changed +45
-2
lines changed
6 files changed +45
-2
lines changed Original file line number Diff line number Diff line change @@ -825,10 +825,14 @@ export default function Image({
825
825
imageSrcSetPropName = 'imageSrcSet'
826
826
imageSizesPropName = 'imageSizes'
827
827
}
828
- const linkProps = {
828
+ const linkProps : React . DetailedHTMLProps <
829
+ React . LinkHTMLAttributes < HTMLLinkElement > ,
830
+ HTMLLinkElement
831
+ > = {
829
832
// Note: imagesrcset and imagesizes are not in the link element type with react 17.
830
833
[ imageSrcSetPropName ] : imgAttributes . srcSet ,
831
834
[ imageSizesPropName ] : imgAttributes . sizes ,
835
+ crossOrigin : rest . crossOrigin ,
832
836
}
833
837
834
838
const onLoadingCompleteRef = useRef ( onLoadingComplete )
Original file line number Diff line number Diff line change @@ -978,10 +978,14 @@ export default function Image({
978
978
imageSrcSetPropName = 'imageSrcSet'
979
979
imageSizesPropName = 'imageSizes'
980
980
}
981
- const linkProps = {
981
+ const linkProps : React . DetailedHTMLProps <
982
+ React . LinkHTMLAttributes < HTMLLinkElement > ,
983
+ HTMLLinkElement
984
+ > = {
982
985
// Note: imagesrcset and imagesizes are not in the link element type with react 17.
983
986
[ imageSrcSetPropName ] : imgAttributes . srcSet ,
984
987
[ imageSizesPropName ] : imgAttributes . sizes ,
988
+ crossOrigin : rest . crossOrigin ,
985
989
}
986
990
987
991
const useLayoutEffect =
Original file line number Diff line number Diff line change @@ -12,6 +12,14 @@ const Page = () => {
12
12
width = "400"
13
13
height = "400"
14
14
> </ Image >
15
+ < Image
16
+ priority
17
+ id = "basic-image-with-crossorigin"
18
+ crossOrigin = "anonymous"
19
+ src = "/test.jpg"
20
+ width = "400"
21
+ height = "400"
22
+ > </ Image >
15
23
< Image
16
24
loading = "eager"
17
25
id = "load-eager"
Original file line number Diff line number Diff line change @@ -141,6 +141,11 @@ function runTests(mode) {
141
141
expect (
142
142
await browser . elementById ( 'basic-image' ) . getAttribute ( 'loading' )
143
143
) . toBe ( null )
144
+ expect (
145
+ await browser
146
+ . elementById ( 'basic-image-with-crossorigin' )
147
+ . getAttribute ( 'loading' )
148
+ ) . toBe ( null )
144
149
expect (
145
150
await browser . elementById ( 'load-eager' ) . getAttribute ( 'loading' )
146
151
) . toBe ( null )
@@ -157,6 +162,13 @@ function runTests(mode) {
157
162
expect ( warnings ) . not . toMatch (
158
163
/ w a s d e t e c t e d a s t h e L a r g e s t C o n t e n t f u l P a i n t / gm
159
164
)
165
+
166
+ // should preload with crossorigin
167
+ expect (
168
+ await browser . elementsByCss (
169
+ 'link[rel=preload][as=image][crossorigin=anonymous][imagesrcset*="test.jpg"]'
170
+ )
171
+ ) . toHaveLength ( 1 )
160
172
} finally {
161
173
if ( browser ) {
162
174
await browser . close ( )
Original file line number Diff line number Diff line change @@ -12,6 +12,14 @@ const Page = () => {
12
12
width = "400"
13
13
height = "400"
14
14
> </ Image >
15
+ < Image
16
+ priority
17
+ id = "basic-image-crossorigin"
18
+ src = "/test.jpg"
19
+ width = "400"
20
+ height = "400"
21
+ crossOrigin = "anonymous"
22
+ > </ Image >
15
23
< Image
16
24
loading = "eager"
17
25
id = "load-eager"
Original file line number Diff line number Diff line change @@ -157,6 +157,13 @@ function runTests(mode) {
157
157
expect ( warnings ) . not . toMatch (
158
158
/ w a s d e t e c t e d a s t h e L a r g e s t C o n t e n t f u l P a i n t / gm
159
159
)
160
+
161
+ // should preload with crossorigin
162
+ expect (
163
+ await browser . elementsByCss (
164
+ 'link[rel=preload][as=image][crossorigin=anonymous][imagesrcset*="test.jpg"]'
165
+ )
166
+ ) . toHaveLength ( 1 )
160
167
} finally {
161
168
if ( browser ) {
162
169
await browser . close ( )
You can’t perform that action at this time.
0 commit comments