Open RedYetiDev opened 2 weeks ago
CC @nodejs/web-standards @nodejs/events
WebKit (https://github.com/WebKit/WebKit/blob/main/Source/WebCore/dom/EventTarget.cpp#L240) does the following:
EventPath eventPath { *this };
event.setTarget(this);
event.setCurrentTarget(this);
event.setEventPhase(Event::AT_TARGET);
event.resetBeforeDispatch();
event.setEventPath(eventPath);
fireEventListeners(event, EventInvokePhase::Capturing);
fireEventListeners(event, EventInvokePhase::Bubbling);
event.resetAfterDispatch();
Where resetAfterDispatch
sets the event target to null
, among other things.
https://dom.spec.whatwg.org/#concept-event-dispatch
- Set event’s currentTarget attribute to null.
While Node.js's
node:events
module provides similar functionality to chromium, it does not comply with the DOM spec.Consider the following code snippet:
In Node.js (and Chromium), this code will log
EventTarget {}
. However, in other engines and browsers, it will lognull
. As a result, Node.js may not be fully compliant withEventTarget-constructible.any.js
.