From 7c19ae302ef5d13f8589a6bf3a2b12af17589e14 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Mon, 21 May 2018 03:00:56 +0200 Subject: [PATCH] replace isEventEmitter with instanceof EventEmitter (rpc-server) (#12998) --- lib/browser/rpc-server.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/browser/rpc-server.js b/lib/browser/rpc-server.js index 271f5c9ac3ac..19e3e7edb7d1 100644 --- a/lib/browser/rpc-server.js +++ b/lib/browser/rpc-server.js @@ -147,17 +147,11 @@ const throwRPCError = function (message) { throw error } -const isEventEmitter = (object) => { - if (!object) return false - const prototype = Object.getPrototypeOf(object) - return prototype === EventEmitter.prototype || isEventEmitter(prototype) -} - const removeRemoteListenersAndLogWarning = (sender, meta, callIntoRenderer) => { let message = `Attempting to call a function in a renderer window that has been closed or released.` + `\nFunction provided here: ${meta.location}` - if (isEventEmitter(sender)) { + if (sender instanceof EventEmitter) { const remoteEvents = sender.eventNames().filter((eventName) => { return sender.listeners(eventName).includes(callIntoRenderer) })