Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 96566fc

Browse filesBrowse files
mikemadesttargos
authored andcommitted
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: #39463 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent afe39ed commit 96566fc
Copy full SHA for 96566fc

File tree

Expand file treeCollapse file tree

2 files changed

+6
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+6
-0
lines changed
Open diff view settings
Collapse file

‎lib/internal/event_target.js‎

Copy file name to clipboardExpand all lines: lib/internal/event_target.js
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ class Event {
168168
stopImmediatePropagation() {
169169
if (!isEvent(this))
170170
throw new ERR_INVALID_THIS('Event');
171+
// Spec mention "stopImmediatePropagation should set both "stop propagation"
172+
// and "stop immediate propagation" flags"
173+
// cf: from https://dom.spec.whatwg.org/#dom-event-stopimmediatepropagation
174+
this.stopPropagation();
171175
this[kStop] = true;
172176
}
173177

Collapse file

‎test/parallel/test-eventtarget.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-eventtarget.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,9 @@ let asyncTest = Promise.resolve();
345345
{
346346
const target = new EventTarget();
347347
const event = new Event('foo');
348+
strictEqual(event.cancelBubble, false);
348349
event.stopImmediatePropagation();
350+
strictEqual(event.cancelBubble, true);
349351
target.addEventListener('foo', common.mustNotCall());
350352
target.dispatchEvent(event);
351353
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.