diff --git a/lib/internal/event_target.js b/lib/internal/event_target.js index 3df88cedf58a3d..8c4ea11a14ed8b 100644 --- a/lib/internal/event_target.js +++ b/lib/internal/event_target.js @@ -8,6 +8,7 @@ const { Set, Symbol, NumberIsNaN, + SymbolToStringTag, } = primordials; const { @@ -67,7 +68,6 @@ class Event { // isTrusted is special (LegacyUnforgeable) Object.defineProperty(this, 'isTrusted', { get() { return false; }, - set(ignoredValue) { return false; }, enumerable: true, configurable: false }); @@ -132,10 +132,15 @@ class Event { stopPropagation() { this.#propagationStopped = true; } - - get [Symbol.toStringTag]() { return 'Event'; } } +Object.defineProperty(Event.prototype, SymbolToStringTag, { + writable: false, + enumerable: false, + configurable: true, + value: 'Event', +}); + // The listeners for an EventTarget are maintained as a linked list. // Unfortunately, the way EventTarget is defined, listeners are accounted // using the tuple [handler,capture], and even if we don't actually make @@ -305,7 +310,6 @@ class EventTarget { return `${name} ${inspect({}, opts)}`; } - get [Symbol.toStringTag]() { return 'EventTarget'; } } Object.defineProperties(EventTarget.prototype, { @@ -313,6 +317,12 @@ Object.defineProperties(EventTarget.prototype, { removeEventListener: { enumerable: true }, dispatchEvent: { enumerable: true } }); +Object.defineProperty(EventTarget.prototype, SymbolToStringTag, { + writable: false, + enumerable: false, + configurable: true, + value: 'EventTarget', +}); class NodeEventTarget extends EventTarget { static defaultMaxListeners = 10;