diff --git a/lib/internal/event_target.js b/lib/internal/event_target.js index 2da787d6388603..c1b8bbcf283dc5 100644 --- a/lib/internal/event_target.js +++ b/lib/internal/event_target.js @@ -164,6 +164,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; } diff --git a/test/parallel/test-eventtarget.js b/test/parallel/test-eventtarget.js index 016d357c9d7c91..9de7c2c41cbd30 100644 --- a/test/parallel/test-eventtarget.js +++ b/test/parallel/test-eventtarget.js @@ -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); }