mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #662] [MERGED] fix(image): strip priority prop before forwarding to UnpicImage to prevent DOM leak #751
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#751
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/662
Author: @james-elicx
Created: 3/22/2026
Status: ✅ Merged
Merged: 3/23/2026
Merged by: @james-elicx
Base:
main← Head:fix/priority-prop-dom-leak📝 Commits (2)
68ad9f1fix(image): strip priority prop before forwarding to UnpicImage to prevent DOM leak5a8a0b1test: add 50ms slack to compressed streaming timing assertion to fix CI flakiness📊 Changes
3 files changed (+105 additions, -3 deletions)
View changed files
📝
packages/vinext/src/shims/image.tsx(+9 -2)📝
tests/features.test.ts(+2 -1)📝
tests/image-component.test.ts(+94 -0)📄 Description
Problem
When using `next/image` with a remote URL and either `fill` or explicit `width`+`height`, the `priority` boolean prop was forwarded directly to `@unpic/react`'s `Image` component. Although `@unpic/core` is supposed to strip it via `transformSharedProps`, in practice it leaked through to the DOM `` element, triggering:
```
Received `true` for a non-boolean attribute `priority`.
If you want to write it to the DOM, pass a string instead: priority="true" or priority={value.toString()}.
```
The two affected code paths were both in `packages/vinext/src/shims/image.tsx`:
Fix
Replace `priority={priority}` on both `` call sites with the equivalent HTML semantics that the local-image and custom-loader paths already use correctly:
```tsx
loading={priority ? "eager" : (loading ?? "lazy")}
fetchPriority={priority ? "high" : undefined}
```
`priority` is a Next.js-specific concept that has no equivalent HTML attribute. It must always be translated to `loading="eager"` + `fetchPriority="high"` before reaching the DOM.
Reproduction
Ten new tests added in `tests/image-component.test.ts` under `"priority prop — no DOM leak on remote URL paths"`:
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.