-
Notifications
You must be signed in to change notification settings - Fork 28.9k
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
events: add initEvent
to Event
#46069
events: add initEvent
to Event
#46069
Conversation
Mdn states that; Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time. |
@anonrig Thank you for checking. BTW, I have one question. mdn states that Refs: https://developer.mozilla.org/en-US/docs/Web/API/Event/cancelBubble |
I believe it will be a breaking change. We should deprecate them, if it’s not, through documentation. |
Thank you for feedback. I'll close this PR soon. |
I actually disagree with @anonrig here. If the spec defines initEvent on EventTarget we have to implement it in order to be spec compliant. And indeed we fail the relevant WPT tests. |
Browsers definitely have to keep supporting it and I think what MDN states is stretching reality. It's probably easier for web developers if Node.js supports it as well so they don't have to adapt code, but I could see an argument for not implementing it. |
@deokjinkim feel free to reopen then :) |
initEvent
to EventinitEvent
to Event
95c95d5
to
f5974f6
Compare
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.
Would be good to add more tests, thanks
initEvent
to EventinitEvent
to Event
@benjamingr Thank you for review. Added description of |
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.
I'm still not in favor of adding a deprecated API to Node.js without any request from a user, just for the goal of spec compliance.
I couldn't find a past example of adding a deprecated API to Node.js. It's not a blocker, but I want to ask @nodejs/tsc opinion about this before merging.
With web standards I feel that you either implement the standard or you don't. This isn't an API like EventEmitter where we get to do as we please - with EventTarget I feel strongly that changes to the API need to be reflected by changes to the spec. I can definitely see an argument for amending the WHATWG DOM spec (which project members have done in the past) to make initEvent optional (by adding it to an annex clients may implement or making it an extension e.g.). |
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.
lgtm
fa88cdb
to
7fdc27d
Compare
Rebased this PR to fix conflict and squashed to 1 commit. |
We've added |
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Landed in 2ff8c50 |
Refs: https://dom.spec.whatwg.org/#dom-event-initevent PR-URL: #46069 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This is not landing cleanly in v18.x |
Refs: https://dom.spec.whatwg.org/#dom-event-initevent