-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
Open
Description
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?
// example.js
let t = new EventTarget()
t.addEventListener('message', (e) => console.log('cancelable?', e.cancelable))
t.dispatchEvent(new MessageEvent('message', { cancelable: true }))node example.jsHow 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.cancelableistruein the event listener for "message'.- Calling
e.preventDefault()will sete.defaultPreventedtotrue.
In other words, I expect the same behavior as with the regular Event instance:
let t = new EventTarget()
t.addEventListener('message', (e) => console.log('cancelable?', e.cancelable))
// Regular Event behaves correctly and can be canceled.
t.dispatchEvent(new Event('message', { cancelable: true }))What do you see instead?
The cancelable attribute on the MessageEvent instance is always false, no matter the cancelable value in the event init dictionary.
Calling e.preventDefault() has no effect on e.defaultPrevented (much likely because the cancelable attribute is false.
Additional information
I'm constructing a MessageEvent that I then dispatch on EventTarget and want to have the listeners being able to cancel that event (prevent its default).
Metadata
Metadata
Assignees
Labels
No labels