From daec67fd15bcaa945349ccaa01f011d68dccc39f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Mar 2026 11:27:06 +0000 Subject: [PATCH 1/2] Initial plan From 0b91e668e296f21ac1a3dbb50fb402ad2735e67f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Mar 2026 11:32:49 +0000 Subject: [PATCH 2/2] fix: pass fetchPriority to img element instead of wrapper div Add fetchPriority to ImageElementProps and COMMON_PROPS so it gets correctly forwarded to the inner img element. Also filter COMMON_PROPS from otherProps to prevent img-specific attributes from leaking to the wrapper div. Closes #270 Co-authored-by: afc163 <507615+afc163@users.noreply.github.com> --- src/Image.tsx | 11 ++++++++++- src/common.ts | 1 + src/interface.ts | 1 + tests/basic.test.tsx | 13 +++++++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/Image.tsx b/src/Image.tsx index 4e37d862..f0894173 100644 --- a/src/Image.tsx +++ b/src/Image.tsx @@ -173,6 +173,15 @@ const ImageInternal: CompoundedComponent = props => { COMMON_PROPS.map(prop => props[prop]), ); + // Filter out img-specific props from wrapper div props + const wrapperProps = useMemo(() => { + const obj = { ...otherProps }; + COMMON_PROPS.forEach((prop: any) => { + delete obj[prop]; + }); + return obj; + }, [otherProps]); + // ========================== Register ========================== const registerData: ImageElementProps = useMemo( () => ({ @@ -207,7 +216,7 @@ const ImageInternal: CompoundedComponent = props => { return ( <>
)[] = [ 'srcSet', 'useMap', 'alt', + 'fetchPriority', ]; diff --git a/src/interface.ts b/src/interface.ts index 42120a73..0c5b1106 100644 --- a/src/interface.ts +++ b/src/interface.ts @@ -13,6 +13,7 @@ export type ImageElementProps = Pick< | 'srcSet' | 'useMap' | 'alt' + | 'fetchPriority' >; export type PreviewImageElementProps = { diff --git a/tests/basic.test.tsx b/tests/basic.test.tsx index 526823e4..13e16c9f 100644 --- a/tests/basic.test.tsx +++ b/tests/basic.test.tsx @@ -51,6 +51,19 @@ describe('Basic', () => { expect(onClickMock).toHaveBeenCalledTimes(1); }); + it('fetchPriority should be passed to img element', () => { + const { container } = render( + , + ); + const img = container.querySelector('img'); + const wrapper = container.querySelector('.rc-image'); + expect(img).toHaveAttribute('fetchpriority', 'high'); + expect(wrapper).not.toHaveAttribute('fetchpriority'); + }); + it('className and style props should work on img element', () => { const { container } = render(