diff --git a/lib/domain.js b/lib/domain.js index cef09dca1c8857..b68e642c490cc3 100644 --- a/lib/domain.js +++ b/lib/domain.js @@ -400,7 +400,7 @@ const eventEmit = EventEmitter.prototype.emit; EventEmitter.prototype.emit = function emit(...args) { const domain = this.domain; if (domain === null || domain === undefined || this === process) { - return eventEmit.apply(this, args); + return Reflect.apply(eventEmit, this, args); } const type = args[0]; @@ -415,7 +415,7 @@ EventEmitter.prototype.emit = function emit(...args) { domain.enter(); try { - return eventEmit.apply(this, args); + return Reflect.apply(eventEmit, this, args); } catch (er) { if (typeof er === 'object' && er !== null) { er.domainEmitter = this; diff --git a/lib/events.js b/lib/events.js index e08cc4f297f400..036758be82a9c4 100644 --- a/lib/events.js +++ b/lib/events.js @@ -123,12 +123,12 @@ EventEmitter.prototype.emit = function emit(type, ...args) { return false; if (typeof handler === 'function') { - handler.apply(this, args); + Reflect.apply(handler, this, args); } else { const len = handler.length; const listeners = arrayClone(handler, len); for (var i = 0; i < len; ++i) - listeners[i].apply(this, args); + Reflect.apply(listeners[i], this, args); } return true; @@ -215,7 +215,7 @@ function onceWrapper(...args) { if (!this.fired) { this.target.removeListener(this.type, this.wrapFn); this.fired = true; - this.listener.apply(this.target, args); + Reflect.apply(this.listener, this.target, args); } }