diff options
author | Benjamin Gruenbaum <benjamingr@gmail.com> | 2020-06-06 21:41:53 +0300 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2020-06-19 01:12:23 +0300 |
commit | ea866dc81b81a71f6ff4c9cb44f8953ce5b398a6 (patch) | |
tree | ce45d902861779a894562a87cca07423920ef66e /lib/internal/event_target.js | |
parent | d7d79f2163b9c7585d187769142da1ca1fa096be (diff) |
events: use property, primordials
PR-URL: https://github.com/nodejs/node/pull/33775
Fixes: https://github.com/nodejs/node/issues/33773
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/internal/event_target.js')
-rw-r--r-- | lib/internal/event_target.js | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/internal/event_target.js b/lib/internal/event_target.js index 3df88cedf58..8c4ea11a14e 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; |