-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
MessageEvent cannot be prevented even if cancelable is true #51767
Comments
This is either an intentional behavior or a bug. In case this is intentional, can we please get some clarification as to why and have the docs updated to mention this behavior difference? Note that both |
The only detail I can spot is that the event init dictionary for the
|
node/lib/internal/worker/io.js Line 131 in fc80168
undici's MessageEvent isn't exposed, I had no idea node implemented it honestly. |
@KhafraDev, it seems to be a global |
A one-liner reproduction:
The base
Can |
This is not reproducible on the latest version of node. I replaced the old MessageEvent with undici's. |
That's good to hear! Thank you so much. Will remove the polyfill once we support v20/v22 as the minimal version. Feel free to close this if the issue is not reproducible. |
Version
v18.14.2 (the same on LTS v20.11.0)
Platform
Darwin imac.home 22.6.0 Darwin Kernel Version 22.6.0: Wed Jul 5 22:21:56 PDT 2023; root:xnu-8796.141.3~6/RELEASE_X86_64 x86_64
Subsystem
No response
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
The issue can be reproduced every time.
What is the expected behavior? Why is that the expected behavior?
I expect the following:
e.cancelable
istrue
in the event listener for "message'.e.preventDefault()
will sete.defaultPrevented
totrue
.In other words, I expect the same behavior as with the regular
Event
instance:What do you see instead?
The
cancelable
attribute on theMessageEvent
instance is alwaysfalse
, no matter thecancelable
value in the event init dictionary.Calling
e.preventDefault()
has no effect one.defaultPrevented
(much likely because thecancelable
attribute isfalse
.Additional information
I'm constructing a
MessageEvent
that I then dispatch onEventTarget
and want to have the listeners being able to cancel that event (prevent its default).The text was updated successfully, but these errors were encountered: