Thanks to visit codestin.com
Credit goes to github.com

Skip to content

enhancement: #236 narrow popovertarget JSX attrs to button/input elements only#237

Merged
thescientist13 merged 1 commit intoProjectEvergreen:masterfrom
LouisLau-art:fix/popovertarget-types
Mar 3, 2026
Merged

enhancement: #236 narrow popovertarget JSX attrs to button/input elements only#237
thescientist13 merged 1 commit intoProjectEvergreen:masterfrom
LouisLau-art:fix/popovertarget-types

Conversation

@LouisLau-art
Copy link
Contributor

Fixes #236.

TypeScript's DOM lib doesn't currently expose popovertarget/popovertargetaction, so WCC adds them manually for JSX typing. Per spec, these attributes should only be valid on and .

Changes:

  • Move popover attributes into a dedicated PopoverTargetAttributes type
  • Apply it conditionally only to the button and input intrinsic elements
  • Add a @ts-expect-error TSX fixture to ensure other tags (e.g. span) error

Verification:

  • npm run lint:types
  • npm test

Copy link
Member

@thescientist13 thescientist13 left a comment

Choose a reason for hiding this comment

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

This looks great, thank you! Great addition of the span test, confirmed it works well 💯
Image

If you could just rebase with the latest in master (there is one conflict from me adding a comment in the jsx.d.ts file) and then there are a couple minor feedback items I left in review, this should be good to go!

type IntrinsicElementsFromDom = {
[E in keyof HTMLElementTagNameMap]: ElementAttributes<HTMLElementTagNameMap[E]>;
[E in keyof HTMLElementTagNameMap]: ElementAttributes<HTMLElementTagNameMap[E]> &
(E extends 'button' | 'input' ? PopoverTargetAttributes : {});
Copy link
Member

Choose a reason for hiding this comment

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

oh yeah, that makes sense! nice, thank you, this looks pretty clean 💯

Close
</button>

{/* @ts-expect-error popovertarget should only be valid on <button> and <input> */}
Copy link
Member

@thescientist13 thescientist13 Feb 6, 2026

Choose a reason for hiding this comment

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

nice, thank you for adding this as a "test" case. Love that TS will error when your @ts-expect-errors are no longer applicable, so this will definitely help catch us if we regress on this in any way.

<button popovertarget="mobile-menu" popovertargetaction="hide">
Close
</button>
<>
Copy link
Member

@thescientist13 thescientist13 Feb 6, 2026

Choose a reason for hiding this comment

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

Although technically this file isn't used for compilation as part of this test case, at present WCC doesn't support fragment tags yet (<> </>) so if we could just use <header> tag or similar here as the wrapping element, that would be great. 👍

@thescientist13 thescientist13 added enhancement Improvement to existing functionality types JSX labels Feb 6, 2026
@thescientist13 thescientist13 changed the title fix(jsx): narrow popovertarget attrs to button/input enhancement(jsx): #236 narrow popovertarget attrs to button/input Feb 6, 2026
@thescientist13 thescientist13 changed the title enhancement(jsx): #236 narrow popovertarget attrs to button/input enhancement: #236 narrow popovertarget JSX attrs to button/input elements only Feb 6, 2026
@LouisLau-art
Copy link
Contributor Author

Thanks for the thorough review and confirmation. I’ll rebase on latest , resolve the conflict in , and address the minor inline feedback in the same follow-up push.

@LouisLau-art
Copy link
Contributor Author

Clarification: I’ll rebase onto latest master, resolve the conflict in src/jsx.d.ts, and then address the remaining inline feedback in the same push.

@LouisLau-art LouisLau-art force-pushed the fix/popovertarget-types branch from 1f66979 to 8792c2e Compare March 3, 2026 01:02
@LouisLau-art
Copy link
Contributor Author

Rebased this branch onto the latest master and force-pushed.

Addressed the review notes:

  • resolved the src/jsx.d.ts rebase conflict while keeping both the issue comment and the narrowed popovertarget typing behavior
  • replaced fragment syntax in the TSX test with a concrete <header> wrapper

Please take another look when you have a moment. Thanks!

@thescientist13
Copy link
Member

Thank you so much @LouisLau-art , looking good! Let me run CI and if all passes, this should be good to merge 💯

@thescientist13 thescientist13 merged commit 3f17c3f into ProjectEvergreen:master Mar 3, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improvement to existing functionality JSX types

Projects

None yet

Development

Successfully merging this pull request may close these issues.

narrow popover related attribute types to just <button> and <input> elements

2 participants