From 1c09dede1a1e8c1100199cd9ddfb2d6861120383 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 1 Nov 2017 23:05:27 -0500 Subject: [PATCH] singletons that are retroactively turned into EventEmitters should call the EventEmitter ctor --- lib/browser/api/app.js | 2 ++ lib/browser/api/auto-updater/auto-updater-native.js | 2 ++ lib/browser/api/net.js | 3 +++ lib/browser/api/power-monitor.js | 2 ++ lib/browser/api/screen.js | 2 ++ lib/browser/api/system-preferences.js | 2 ++ lib/renderer/api/web-frame.js | 1 + 7 files changed, 14 insertions(+) diff --git a/lib/browser/api/app.js b/lib/browser/api/app.js index d1ca60280e..381a2a8663 100644 --- a/lib/browser/api/app.js +++ b/lib/browser/api/app.js @@ -10,7 +10,9 @@ const electron = require('electron') const {deprecate, Menu} = electron const {EventEmitter} = require('events') +// App is an EventEmitter. Object.setPrototypeOf(App.prototype, EventEmitter.prototype) +EventEmitter.call(app) Object.assign(app, { setApplicationMenu (menu) { diff --git a/lib/browser/api/auto-updater/auto-updater-native.js b/lib/browser/api/auto-updater/auto-updater-native.js index 80e2eb1b84..cdd390d0a5 100644 --- a/lib/browser/api/auto-updater/auto-updater-native.js +++ b/lib/browser/api/auto-updater/auto-updater-native.js @@ -1,6 +1,8 @@ const EventEmitter = require('events').EventEmitter const {autoUpdater, AutoUpdater} = process.atomBinding('auto_updater') +// AutoUpdater is an EventEmitter. Object.setPrototypeOf(AutoUpdater.prototype, EventEmitter.prototype) +EventEmitter.call(autoUpdater) module.exports = autoUpdater diff --git a/lib/browser/api/net.js b/lib/browser/api/net.js index d32f6946ee..330faa82a8 100644 --- a/lib/browser/api/net.js +++ b/lib/browser/api/net.js @@ -9,7 +9,10 @@ const {Session} = process.atomBinding('session') const {net, Net} = process.atomBinding('net') const {URLRequest} = net +// Net is an EventEmitter. Object.setPrototypeOf(Net.prototype, EventEmitter.prototype) +EventEmitter.call(net) + Object.setPrototypeOf(URLRequest.prototype, EventEmitter.prototype) const kSupportedProtocols = new Set(['http:', 'https:']) diff --git a/lib/browser/api/power-monitor.js b/lib/browser/api/power-monitor.js index aee9b450c8..e1dff2c3b7 100644 --- a/lib/browser/api/power-monitor.js +++ b/lib/browser/api/power-monitor.js @@ -1,6 +1,8 @@ const {EventEmitter} = require('events') const {powerMonitor, PowerMonitor} = process.atomBinding('power_monitor') +// PowerMonitor is an EventEmitter. Object.setPrototypeOf(PowerMonitor.prototype, EventEmitter.prototype) +EventEmitter.call(powerMonitor) module.exports = powerMonitor diff --git a/lib/browser/api/screen.js b/lib/browser/api/screen.js index 83381ab5d7..8287bfa8bf 100644 --- a/lib/browser/api/screen.js +++ b/lib/browser/api/screen.js @@ -1,6 +1,8 @@ const {EventEmitter} = require('events') const {screen, Screen} = process.atomBinding('screen') +// Screen is an EventEmitter. Object.setPrototypeOf(Screen.prototype, EventEmitter.prototype) +EventEmitter.call(screen) module.exports = screen diff --git a/lib/browser/api/system-preferences.js b/lib/browser/api/system-preferences.js index 7d9d475bc2..e4485d3d87 100644 --- a/lib/browser/api/system-preferences.js +++ b/lib/browser/api/system-preferences.js @@ -1,6 +1,8 @@ const {EventEmitter} = require('events') const {systemPreferences, SystemPreferences} = process.atomBinding('system_preferences') +// SystemPreferences is an EventEmitter. Object.setPrototypeOf(SystemPreferences.prototype, EventEmitter.prototype) +EventEmitter.call(systemPreferences) module.exports = systemPreferences diff --git a/lib/renderer/api/web-frame.js b/lib/renderer/api/web-frame.js index f9d2b3b191..3241858cfa 100644 --- a/lib/renderer/api/web-frame.js +++ b/lib/renderer/api/web-frame.js @@ -5,6 +5,7 @@ const {webFrame, WebFrame} = process.atomBinding('web_frame') // WebFrame is an EventEmitter. Object.setPrototypeOf(WebFrame.prototype, EventEmitter.prototype) +EventEmitter.call(webFrame) // Lots of webview would subscribe to webFrame's events. webFrame.setMaxListeners(0)