-
-
Notifications
You must be signed in to change notification settings - Fork 2k
types: Refactor 'AllHTMLAttributes' interface #4706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| interface DetailsHTMLAttributes<T extends EventTarget = HTMLDetailsElement> | ||
| extends HTMLAttributes<T> { | ||
| open?: Signalish<boolean | undefined>; | ||
| onToggle?: GenericEventHandler<T> | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| h('form', { onSubmit: onSubmit }); | ||
|
|
||
| // Should accept onToggle | ||
| const onToggle = (e: h.JSX.TargetedToggleEvent<HTMLDetailsElement>) => {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be HTMLDialogElement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Er yes, yes it should. I think that was a typo.
On the other hand, it does show that our h and createElement types aren't quite correct as they'll accept handlers with generics for other elements than their own. IIUC, the way to fix this is add a h & createElement type definition for every single element.
dc5544e to
61d9e86
Compare
In the interest of reducing the maintenance burden of having per-element type interfaces AND the legacy
AllHTMLAttributesinterface, which should theoretically be kept in sync, this converts the latter into an extension of every per-element interface we have.Doing so has caught a few errors already, though there's a limited few properties that have to become
anywhen used from this interface (HTMLInputElement.typevsHTMLAnchorElement.type, for instance).