Skip to content

fix: pass fetchPriority to img element instead of wrapper div#501

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-fetchpriority-propagation
Draft

fix: pass fetchPriority to img element instead of wrapper div#501
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-fetchpriority-propagation

Conversation

Copy link
Contributor

Copilot AI commented Mar 17, 2026

fetchPriority was not included in ImageElementProps/COMMON_PROPS, so it fell through to ...otherProps and got spread onto the wrapper <div> instead of the inner <img>.

  • Added fetchPriority to ImageElementProps type and COMMON_PROPS array
  • Filter COMMON_PROPS out of otherProps before spreading on the wrapper <div>, preventing img-specific attributes from leaking to the wrapper
// Before: fetchPriority ends up on the wrapper div
<Image src="example.png" fetchPriority="high" />
// <div fetchpriority="high">  ← wrong
//   <img />
// </div>

// After: fetchPriority correctly reaches the img element
// <div>
//   <img fetchpriority="high" />  ← correct
// </div>
Original prompt

This section details on the original issue you should resolve

<issue_title>Image 组件的 fetchPriority 属性无法正常传递给内部 img 节点,错误作用在了外部的 div 节点</issue_title>
<issue_description>### Reproduction link

https://github.com/wangshu-g/antd-Image-fetchPriority

Steps to reproduce

git clone https://github.com/wangshu-g/antd-Image-fetchPriority
cd antd-Image-fetchPriority
npm install
npm run dev
// F12 查看源代码
// fetchPriority 属性没有正确传递给内部的 img 节点上
// 而是错误地出现在了外部的 div 节点

What is expected?

期望 Image 组件的 fetchPriority 属性可以正常传递到内部 img 节点上

What is actually happening?

目前 fetchPriority 属性无法正确传递

Environment Info
antd 6.3.3
React 18.2.0
System Ubuntu Resolute Raccoon (development branch) x86_64
Browser Microsoft Edge 145.0.3800.82 (正式版本) (64 位)

该属性提供获取图像时应使用的相对优先级提示

Comments on the Issue (you are @copilot in this section)


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

@vercel
Copy link

vercel bot commented Mar 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
image Error Error Mar 17, 2026 11:32am

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>
Copilot AI changed the title [WIP] Fix fetchPriority attribute propagation in Image component fix: pass fetchPriority to img element instead of wrapper div Mar 17, 2026
Copilot AI requested a review from afc163 March 17, 2026 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Image 组件的 fetchPriority 属性无法正常传递给内部 img 节点,错误作用在了外部的 div 节点

2 participants