Skip to content

fix: pass fetchPriority prop to img element#504

Merged
zombieJ merged 1 commit intoreact-component:masterfrom
aojunhao123:fix/fetchPriority-passthrough
Mar 22, 2026
Merged

fix: pass fetchPriority prop to img element#504
zombieJ merged 1 commit intoreact-component:masterfrom
aojunhao123:fix/fetchPriority-passthrough

Conversation

@aojunhao123
Copy link
Contributor

@aojunhao123 aojunhao123 commented Mar 22, 2026

Summary

  • Add fetchPriority to ImageElementProps type and COMMON_PROPS whitelist so it correctly passes through to the <img> element instead of the wrapper <div>
  • Add unit test to verify the prop is rendered on the <img> tag

Test plan

  • pnpm test — all 66 tests pass
  • Verify fetchPriority attribute appears on the <img> element in browser DevTools

Summary by CodeRabbit

发布说明

  • 新功能

    • 添加了图片元素的 fetchPriority 属性支持,允许优化资源加载优先级
  • 测试

    • 新增测试用例验证 fetchPriority 属性的功能

@vercel
Copy link

vercel bot commented Mar 22, 2026

@aojunhao123 is attempting to deploy a commit to the React Component Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link

coderabbitai bot commented Mar 22, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fdc1250f-99f7-4eb6-8ddc-c2ea27eb840d

📥 Commits

Reviewing files that changed from the base of the PR and between 718a756 and 792c684.

📒 Files selected for processing (3)
  • src/common.ts
  • src/interface.ts
  • tests/basic.test.tsx

概要

此改动在 ImageElementProps 类型和相关常量中添加了 fetchPriority 属性支持,包括更新类型定义、导出常量列表,以及添加验证该属性的测试用例。

变更

内聚组/文件 摘要
类型定义与常量更新
src/interface.ts, src/common.ts
ImageElementProps 类型定义中添加 'fetchPriority',并将其加入 COMMON_PROPS 常量数组以支持图像元素的 fetchPriority 属性。
测试覆盖
tests/basic.test.tsx
新增测试用例,验证 Image 组件渲染时正确传递并设置 fetchPriority="high" 属性。

估计的代码审查工作量

🎯 2 (Simple) | ⏱️ ~10 分钟

建议的审查者

  • thinkasany
  • zombieJ

诗歌

🐰 新属性添入小仓库,
fetchPriority 轻轻地落,
图片加载更优先,
类型安全放心坐,
测试覆盖无遗漏!✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题清晰准确地总结了主要变更:添加对fetchPriority属性的透传支持到img元素,与所有文件修改的核心目的一致。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can disable sequence diagrams in the walkthrough.

Disable the reviews.sequence_diagrams setting to disable sequence diagrams in the walkthrough.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the Image component by enabling the fetchPriority attribute to be passed directly to the underlying <img> element. This allows developers to optimize image loading based on their specific needs. The changes include updating the component's props interface and adding a unit test to ensure the functionality works as expected.

Highlights

  • Feature Addition: The fetchPriority prop is now correctly passed to the <img> element, allowing control over image loading priority.
  • Type Definition Update: The ImageElementProps type has been updated to include fetchPriority.
  • Test Coverage: A new unit test has been added to verify that the fetchPriority prop is rendered on the <img> tag.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for the fetchPriority prop to the Image component, allowing it to be passed down to the underlying <img> element. The changes include updating the ImageElementProps type and the COMMON_PROPS whitelist to recognize the new prop. A unit test has also been added to verify that the fetchPriority attribute is correctly rendered on the <img> tag. The implementation is correct and effectively addresses the issue.

@zombieJ zombieJ merged commit 82e5175 into react-component:master Mar 22, 2026
5 of 6 checks passed
@codecov
Copy link

codecov bot commented Mar 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.41%. Comparing base (718a756) to head (792c684).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #504   +/-   ##
=======================================
  Coverage   99.41%   99.41%           
=======================================
  Files          17       17           
  Lines         511      511           
  Branches      153      153           
=======================================
  Hits          508      508           
  Misses          3        3           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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