Skip to content

fix(types): add referrerPolicy to ImgHTMLAttributes#6694

Merged
johnjenkins merged 1 commit intostenciljs:mainfrom
civing:fix/img-referrer-policy
Apr 30, 2026
Merged

fix(types): add referrerPolicy to ImgHTMLAttributes#6694
johnjenkins merged 1 commit intostenciljs:mainfrom
civing:fix/img-referrer-policy

Conversation

@civing
Copy link
Copy Markdown
Contributor

@civing civing commented Apr 30, 2026

What is the current behavior?

JSXBase.ImgHTMLAttributes is missing the referrerPolicy attribute, so this fails type-checking:

<img src="https://example.com/icon.png" referrerPolicy="no-referrer" />
// Property 'referrerPolicy' does not exist on type
// 'ImgHTMLAttributes<HTMLImageElement>'.

Consumers have to cast as any to compile, which is noisy and obscures intent. The attribute already exists on the sibling JSX types AnchorHTMLAttributes and IframeHTMLAttributes.

GitHub Issue Number: #6692

What is the new behavior?

Adds referrerPolicy?: ReferrerPolicy; to ImgHTMLAttributes in src/declarations/stencil-public-runtime.ts, mirroring the existing declarations on AnchorHTMLAttributes (line 1056) and IframeHTMLAttributes (line 1191). The ReferrerPolicy type is provided by the TypeScript DOM lib; no additional imports and no runtime impact, since this only affects JSX type checking.

This brings <img> in line with the HTML spec and matches prior fixes for the same gap on sibling elements:

Documentation

N/A — JSX type addition.

Does this introduce a breaking change?

  • Yes
  • No

Testing

Other information

Real-world motivation: a CRM web-components library needs referrerpolicy="no-referrer" on rendered <img> to suppress the Referer header when the image source is a third-party favicon service, so the originating CRM page URL doesn't leak to the third party.

Mirror the existing declarations on AnchorHTMLAttributes and
IframeHTMLAttributes so <img referrerpolicy="..."> type-checks
without an `as any` cast. The ReferrerPolicy type is provided
by the TypeScript DOM lib; no runtime impact.

fixes: stenciljs#6692
Copilot AI review requested due to automatic review settings April 30, 2026 12:25
@civing civing requested a review from a team as a code owner April 30, 2026 12:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds the missing referrerPolicy JSX typing to Stencil’s <img> attributes so consumers can set referrerPolicy="no-referrer" (and related values) without any casts, matching existing support on <a> and <iframe>.

Changes:

  • Add referrerPolicy?: ReferrerPolicy; to JSXBase.ImgHTMLAttributes.
  • Align <img> JSX typings with the existing referrerPolicy declarations already present for AnchorHTMLAttributes and IframeHTMLAttributes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@johnjenkins johnjenkins added this pull request to the merge queue Apr 30, 2026
Merged via the queue into stenciljs:main with commit 3ed82f1 Apr 30, 2026
58 of 60 checks passed
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.

3 participants