-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
SubmitEvent.submitter should be HTMLButtonElement instead of HTMLElement #7038
Comments
I don't think it would be "more correct"; HTMLElement is correct, in that everything returned by that is a HTMLElement or null. In general we avoid using unions for return types in the way you're suggesting, since it makes spec maintenance harder. (For example, we would then need to update it if we ever solve WICG/webcomponents#814.) I'll close this since I don't think we should change the spec here, but I'm happy to continue discussing in the closed thread. Also I have no idea what language you're using in your code example; it doesn't appear in the spec. |
Thank you for your detailed response and patience! I hope my lack of in-depth knowledge about this is apparent. It makes sense to avoid unions, and in that case I would still suggest to make the return type solely a The practical reason for my proposal - which I know perhaps isn't really any concern of whatwg - is that the whatwg spec is the source of truth for the dom.generated.d.ts-file by the DefinitelyTyped-project, which in turn serves as the source of truth for all TypeScript-projects, and for the IntelliSense provided in eg. Visual Studio Code. As of now, if you want to access The language in the code example is IDL with a coating of TypeScript on the first line :) |
Yeah, I think this is best addressed on the TypeScript side. Using HTMLButtonElement would be incorrect, because then the spec would not be allowed to set it to |
Hi!
Currently
submitter
in theSubmitEvent
interface is typed as aHTMLElement
, but an element of this type has novalue
property by default, and furthermore thesubmitter
can only ever be of typeHTMLButtonElement
,HTMLInputElement
ornull
.Would this not be more correct?
Link to spec: https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#the-submitevent-interface:submiteventinit
The text was updated successfully, but these errors were encountered: