enhancement: #236 narrow popovertarget JSX attrs to button/input elements only#237
Conversation
thescientist13
left a comment
There was a problem hiding this comment.
This looks great, thank you! Great addition of the span test, confirmed it works well 💯

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 : {}); |
There was a problem hiding this comment.
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> */} |
There was a problem hiding this comment.
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.
test/cases/tsx/src/header.tsx
Outdated
| <button popovertarget="mobile-menu" popovertargetaction="hide"> | ||
| Close | ||
| </button> | ||
| <> |
There was a problem hiding this comment.
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. 👍
|
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. |
|
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. |
1f66979 to
8792c2e
Compare
|
Rebased this branch onto the latest Addressed the review notes:
Please take another look when you have a moment. Thanks! |
|
Thank you so much @LouisLau-art , looking good! Let me run CI and if all passes, this should be good to merge 💯 |
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:
PopoverTargetAttributestype@ts-expect-errorTSX fixture to ensure other tags (e.g. span) errorVerification: