From d9b5cd533c5b555175017faa973fcdf532288802 Mon Sep 17 00:00:00 2001 From: "mert.altin" Date: Thu, 26 Oct 2023 10:05:59 +0300 Subject: [PATCH] events: no stopPropagation call in cancelBubble PR-URL: https://github.com/nodejs/node/pull/50405 Reviewed-By: Matthew Aitken Reviewed-By: Benjamin Gruenbaum Reviewed-By: Deokjin Kim Reviewed-By: James M Snell Reviewed-By: Michael Dawson --- lib/internal/event_target.js | 2 +- test/parallel/test-eventtarget.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/internal/event_target.js b/lib/internal/event_target.js index 67a84f55853770..9d9ad1f222b903 100644 --- a/lib/internal/event_target.js +++ b/lib/internal/event_target.js @@ -310,7 +310,7 @@ class Event { if (!isEvent(this)) throw new ERR_INVALID_THIS('Event'); if (value) { - this.stopPropagation(); + this.#propagationStopped = true; } } diff --git a/test/parallel/test-eventtarget.js b/test/parallel/test-eventtarget.js index 193c47893b5a9e..aaead823d032b8 100644 --- a/test/parallel/test-eventtarget.js +++ b/test/parallel/test-eventtarget.js @@ -738,3 +738,10 @@ let asyncTest = Promise.resolve(); controller.abort(); et.dispatchEvent(new Event('foo')); } + +{ + const event = new Event('foo'); + strictEqual(event.cancelBubble, false); + event.cancelBubble = true; + strictEqual(event.cancelBubble, true); +}