From 792c684fda250558f04037573f931fc6a6d578c0 Mon Sep 17 00:00:00 2001 From: aojunhao123 <1844749591@qq.com> Date: Sun, 22 Mar 2026 22:22:43 +0800 Subject: [PATCH] fix: pass fetchPriority prop to img element --- src/common.ts | 1 + src/interface.ts | 1 + tests/basic.test.tsx | 11 +++++++++++ 3 files changed, 13 insertions(+) diff --git a/src/common.ts b/src/common.ts index a52a58ae..abaaf1fe 100644 --- a/src/common.ts +++ b/src/common.ts @@ -10,4 +10,5 @@ export const COMMON_PROPS: (keyof Omit)[] = [ '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..243d0870 100644 --- a/tests/basic.test.tsx +++ b/tests/basic.test.tsx @@ -51,6 +51,17 @@ describe('Basic', () => { expect(onClickMock).toHaveBeenCalledTimes(1); }); + it('should pass fetchPriority to img element', () => { + const { container } = render( + , + ); + const img = container.querySelector('img'); + expect(img).toHaveAttribute('fetchpriority', 'high'); + }); + it('className and style props should work on img element', () => { const { container } = render(