Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 8 additions & 16 deletions lib/internal/event_target.js
Original file line number Diff line number Diff line change
Expand Up @@ -791,14 +791,6 @@ class EventTarget {
}

[kHybridDispatch](nodeValue, type, event) {
const createEvent = () => {
if (event === undefined) {
event = this[kCreateEvent](nodeValue, type);
event[kTarget] = this;
event[kIsBeingDispatched] = true;
}
return event;
};
if (event !== undefined) {
event[kTarget] = this;
event[kIsBeingDispatched] = true;
Expand All @@ -814,13 +806,8 @@ class EventTarget {
let handler = root.next;
let next;

const iterationCondition = () => {
if (handler === undefined) {
return false;
}
return root.resistStopPropagation || handler.passive || event?.[kStop] !== true;
};
while (iterationCondition()) {
while (handler !== undefined &&
(root.resistStopPropagation || handler.passive || event?.[kStop] !== true)) {
// Cache the next item in case this iteration removes the current one
next = handler.next;

Expand All @@ -844,7 +831,12 @@ class EventTarget {
if (handler.isNodeStyleListener) {
arg = nodeValue;
} else {
arg = createEvent();
if (event === undefined) {
event = this[kCreateEvent](nodeValue, type);
event[kTarget] = this;
event[kIsBeingDispatched] = true;
}
arg = event;
}
const callback = handler.weak ?
handler.callback.deref() : handler.callback;
Expand Down
Loading