fix(types): add referrerPolicy to ImgHTMLAttributes#6694
Merged
johnjenkins merged 1 commit intostenciljs:mainfrom Apr 30, 2026
Merged
fix(types): add referrerPolicy to ImgHTMLAttributes#6694johnjenkins merged 1 commit intostenciljs:mainfrom
johnjenkins merged 1 commit intostenciljs:mainfrom
Conversation
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
Contributor
There was a problem hiding this comment.
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;toJSXBase.ImgHTMLAttributes. - Align
<img>JSX typings with the existingreferrerPolicydeclarations already present forAnchorHTMLAttributesandIframeHTMLAttributes.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
johnjenkins
approved these changes
Apr 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the current behavior?
JSXBase.ImgHTMLAttributesis missing thereferrerPolicyattribute, so this fails type-checking:Consumers have to cast as
anyto compile, which is noisy and obscures intent. The attribute already exists on the sibling JSX typesAnchorHTMLAttributesandIframeHTMLAttributes.GitHub Issue Number: #6692
What is the new behavior?
Adds
referrerPolicy?: ReferrerPolicy;toImgHTMLAttributesinsrc/declarations/stencil-public-runtime.ts, mirroring the existing declarations onAnchorHTMLAttributes(line 1056) andIframeHTMLAttributes(line 1191). TheReferrerPolicytype 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:<iframe>: fix(jsx): add referrerPolicy for iframe interface #2003 (2020) —fix(jsx): add referrerPolicy for iframe interface<a>: Add referrerPolicy to AnchorHTMLAttributes #3006 (2021) —fix(types): add referrerPolicy to AnchorHTMLAttributesDocumentation
N/A — JSX type addition.
Does this introduce a breaking change?
Testing
npm run buildsucceeds.Other information
Real-world motivation: a CRM web-components library needs
referrerpolicy="no-referrer"on rendered<img>to suppress theRefererheader when the image source is a third-party favicon service, so the originating CRM page URL doesn't leak to the third party.