mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
events: add stop propagation flag to Event.stopImmediatePropagation
Spec mention stopImmediatePropagation should set both flags: "stop propagation" and "stop immediate propagation". So the second is not supported by Node.js as there is no hierarchy and bubbling, but the flags are both present as well as stopPropagation. It would makes sense to follow specs on that. Refs: https://dom.spec.whatwg.org/#dom-event-stopimmediatepropagation PR-URL: https://github.com/nodejs/node/pull/39463 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This commit is contained in:
parent
0fa07d4442
commit
04cf8c2130
@ -168,6 +168,10 @@ class Event {
|
||||
stopImmediatePropagation() {
|
||||
if (!isEvent(this))
|
||||
throw new ERR_INVALID_THIS('Event');
|
||||
// Spec mention "stopImmediatePropagation should set both "stop propagation"
|
||||
// and "stop immediate propagation" flags"
|
||||
// cf: from https://dom.spec.whatwg.org/#dom-event-stopimmediatepropagation
|
||||
this.stopPropagation();
|
||||
this[kStop] = true;
|
||||
}
|
||||
|
||||
|
@ -345,7 +345,9 @@ let asyncTest = Promise.resolve();
|
||||
{
|
||||
const target = new EventTarget();
|
||||
const event = new Event('foo');
|
||||
strictEqual(event.cancelBubble, false);
|
||||
event.stopImmediatePropagation();
|
||||
strictEqual(event.cancelBubble, true);
|
||||
target.addEventListener('foo', common.mustNotCall());
|
||||
target.dispatchEvent(event);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user