Skip to content

Commit 82e5175

Browse files
authored
fix: pass fetchPriority prop to img element (#504)
1 parent 718a756 commit 82e5175

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

src/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ export const COMMON_PROPS: (keyof Omit<ImageElementProps, 'src'>)[] = [
1010
'srcSet',
1111
'useMap',
1212
'alt',
13+
'fetchPriority',
1314
];

src/interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export type ImageElementProps = Pick<
1313
| 'srcSet'
1414
| 'useMap'
1515
| 'alt'
16+
| 'fetchPriority'
1617
>;
1718

1819
export type PreviewImageElementProps = {

tests/basic.test.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ describe('Basic', () => {
5151
expect(onClickMock).toHaveBeenCalledTimes(1);
5252
});
5353

54+
it('should pass fetchPriority to img element', () => {
55+
const { container } = render(
56+
<Image
57+
src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
58+
fetchPriority="high"
59+
/>,
60+
);
61+
const img = container.querySelector('img');
62+
expect(img).toHaveAttribute('fetchpriority', 'high');
63+
});
64+
5465
it('className and style props should work on img element', () => {
5566
const { container } = render(
5667
<Image

0 commit comments

Comments
 (0)