Skip to content
Merged
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
11 changes: 1 addition & 10 deletions lib/internal/event_target.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,15 +408,6 @@ ObjectDefineProperties(CustomEvent.prototype, {
detail: kEnumerableProperty,
});

class NodeCustomEvent extends Event {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you keep this as class NodeCustomEvent extends CustomEvent {}, that might even be a bit nicer since it’s a way to differentiate between events coming from a user and events coming from a Node.js EventEmitter .emit() call?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you help me understand what specific usercase do we need to support? I don't understand in which scenario we would need to differentiate between events coming from a user and events coming from a Node.js EventEmitter .emit() call.

constructor(type, options) {
super(type, options);
if (options?.detail) {
this.detail = options.detail;
}
}
}

// Weak listener cleanup
// This has to be lazy for snapshots to work
let weakListenersState = null;
Expand Down Expand Up @@ -837,7 +828,7 @@ class EventTarget {
}

[kCreateEvent](nodeValue, type) {
return new NodeCustomEvent(type, { detail: nodeValue });
return new CustomEvent(type, { detail: nodeValue });
}
[customInspectSymbol](depth, options) {
if (!isEventTarget(this))
Expand Down