Skip to content

Commit 23744d2

Browse files
Mickael MeausooneMickael Meausoone
Mickael Meausoone
authored and
Mickael Meausoone
committed
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 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
1 parent 3cbaabc commit 23744d2

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/internal/event_target.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ class Event {
125125
}
126126

127127
stopImmediatePropagation() {
128+
// Spec mention "stopImmediatePropagation should set both "stop propagation"
129+
// and "stop immediate propagation" flags"
130+
// cf: from https://dom.spec.whatwg.org/#dom-event-stopimmediatepropagation
131+
this.stopPropagation();
128132
this[kStop] = true;
129133
}
130134

test/parallel/test-eventtarget.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,9 @@ let asyncTest = Promise.resolve();
267267
{
268268
const target = new EventTarget();
269269
const event = new Event('foo');
270+
strictEqual(event.cancelBubble, false);
270271
event.stopImmediatePropagation();
272+
strictEqual(event.cancelBubble, true);
271273
target.addEventListener('foo', common.mustNotCall());
272274
target.dispatchEvent(event);
273275
}

0 commit comments

Comments
 (0)