From 576b888593fb6d69ef2b0b75495cdd2c37fa452d Mon Sep 17 00:00:00 2001 From: jdecroock Date: Sun, 3 Sep 2023 13:25:16 +0200 Subject: [PATCH] remove bubbles --- src/diff/props.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/diff/props.js b/src/diff/props.js index ecfcff8a4f..0ff5b2d26a 100644 --- a/src/diff/props.js +++ b/src/diff/props.js @@ -161,9 +161,13 @@ function eventProxy(e) { * when the dom performs an event it leaves micro-ticks in between bubbling up which means that an event can trigger on a newly * created DOM-node while the event bubbles up, this can cause quirky behavior as seen in https://github.com/preactjs/preact/issues/3927 */ - if (!e._dispatched && e.bubbles) { + if (!e._dispatched) { + // When an event has no _dispatched we know this is the first event-target in the chain + // so we set the initial dispatched time. e._dispatched = Date.now(); - } else if (e._dispatched && e._dispatched <= eventHandler._attached) { + // When the _dispatched is smaller than the time when the targetted event handler was attached + // we know we have bubbled up to an element that was added during patching the dom. + } else if (e._dispatched <= eventHandler._attached) { return; } return eventHandler(options.event ? options.event(e) : e);