diff options
author | Michaël Zasso <targos@protonmail.com> | 2020-09-27 18:39:01 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2020-09-30 18:52:35 +0300 |
commit | a8806535d9e7db7bf20b3b3ef8f911320baf7511 (patch) | |
tree | 157eb786752ca8ed6f59e0a5a4cab6435016a53a /lib/internal/event_target.js | |
parent | a77f2ea6d436402ef4c197a470fcb3bd3a3037cd (diff) |
lib: use Object static properties from primordials
PR-URL: https://github.com/nodejs/node/pull/35380
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Ricky Zhou <0x19951125@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Diffstat (limited to 'lib/internal/event_target.js')
-rw-r--r-- | lib/internal/event_target.js | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/internal/event_target.js b/lib/internal/event_target.js index 8f0657c8d5b..f9dda75f046 100644 --- a/lib/internal/event_target.js +++ b/lib/internal/event_target.js @@ -6,7 +6,8 @@ const { Error, Map, NumberIsInteger, - Object, + ObjectAssign, + ObjectDefineProperties, ObjectDefineProperty, Symbol, SymbolFor, @@ -89,7 +90,7 @@ class Event { if (depth < 0) return name; - const opts = Object.assign({}, options, { + const opts = ObjectAssign({}, options, { depth: NumberIsInteger(options.depth) ? options.depth - 1 : options.depth }); @@ -151,7 +152,7 @@ class Event { static BUBBLING_PHASE = 3; } -Object.defineProperty(Event.prototype, SymbolToStringTag, { +ObjectDefineProperty(Event.prototype, SymbolToStringTag, { writable: false, enumerable: false, configurable: true, @@ -369,7 +370,7 @@ class EventTarget { if (depth < 0) return name; - const opts = Object.assign({}, options, { + const opts = ObjectAssign({}, options, { depth: NumberIsInteger(options.depth) ? options.depth - 1 : options.depth }); @@ -377,12 +378,12 @@ class EventTarget { } } -Object.defineProperties(EventTarget.prototype, { +ObjectDefineProperties(EventTarget.prototype, { addEventListener: { enumerable: true }, removeEventListener: { enumerable: true }, dispatchEvent: { enumerable: true } }); -Object.defineProperty(EventTarget.prototype, SymbolToStringTag, { +ObjectDefineProperty(EventTarget.prototype, SymbolToStringTag, { writable: false, enumerable: false, configurable: true, @@ -477,7 +478,7 @@ class NodeEventTarget extends EventTarget { } } -Object.defineProperties(NodeEventTarget.prototype, { +ObjectDefineProperties(NodeEventTarget.prototype, { setMaxListeners: { enumerable: true }, getMaxListeners: { enumerable: true }, eventNames: { enumerable: true }, @@ -545,7 +546,7 @@ function emitUnhandledRejectionOrErr(that, err, event) { function defineEventHandler(emitter, name) { // 8.1.5.1 Event handlers - basically `on[eventName]` attributes let eventHandlerValue; - Object.defineProperty(emitter, `on${name}`, { + ObjectDefineProperty(emitter, `on${name}`, { get() { return eventHandlerValue; }, |