Browse Source

replace __proto__ with Object.setPrototype

Zeke Sikelianos 9 years ago
parent
commit
4e2f1311e0

+ 2 - 2
lib/browser/api/app.js

@@ -9,7 +9,7 @@ const bindings = process.atomBinding('app')
 const downloadItemBindings = process.atomBinding('download_item')
 const app = bindings.app
 
-app.__proto__ = EventEmitter.prototype
+Object.setPrototypeOf(app, EventEmitter.prototype)
 
 app.setApplicationMenu = function (menu) {
   return Menu.setApplicationMenu(menu)
@@ -102,7 +102,7 @@ deprecate.event(app, 'select-certificate', 'select-client-certificate')
 // Wrappers for native classes.
 var wrapDownloadItem = function (downloadItem) {
   // downloadItem is an EventEmitter.
-  downloadItem.__proto__ = EventEmitter.prototype
+  Object.setPrototypeOf(downloadItem, EventEmitter.prototype)
 
   // Deprecated.
   deprecate.property(downloadItem, 'url', 'getURL')

+ 1 - 1
lib/browser/api/auto-updater/auto-updater-native.js

@@ -1,6 +1,6 @@
 const EventEmitter = require('events').EventEmitter
 const autoUpdater = process.atomBinding('auto_updater').autoUpdater
 
-autoUpdater.__proto__ = EventEmitter.prototype
+Object.setPrototypeOf(autoUpdater, EventEmitter.prototype)
 
 module.exports = autoUpdater

+ 1 - 1
lib/browser/api/browser-window.js

@@ -5,7 +5,7 @@ const deprecate = require('electron').deprecate
 const EventEmitter = require('events').EventEmitter
 const {BrowserWindow, _setDeprecatedOptionsCheck} = process.atomBinding('window')
 
-BrowserWindow.prototype.__proto__ = EventEmitter.prototype
+Object.setPrototypeOf(BrowserWindow.prototype, EventEmitter.prototype)
 
 BrowserWindow.prototype._init = function () {
   // avoid recursive require.

+ 1 - 1
lib/browser/api/menu.js

@@ -87,7 +87,7 @@ var indexToInsertByPosition = function (items, position) {
 
 const Menu = bindings.Menu
 
-Menu.prototype.__proto__ = EventEmitter.prototype
+Object.setPrototypeOf(Menu.prototype, EventEmitter.prototype)
 
 Menu.prototype._init = function () {
   this.commandsMap = {}

+ 1 - 1
lib/browser/api/power-monitor.js

@@ -1,6 +1,6 @@
 const EventEmitter = require('events').EventEmitter
 const powerMonitor = process.atomBinding('power_monitor').powerMonitor
 
-powerMonitor.__proto__ = EventEmitter.prototype
+Object.setPrototypeOf(powerMonitor, EventEmitter.prototype)
 
 module.exports = powerMonitor

+ 1 - 1
lib/browser/api/screen.js

@@ -1,6 +1,6 @@
 const EventEmitter = require('events').EventEmitter
 const screen = process.atomBinding('screen').screen
 
-screen.__proto__ = EventEmitter.prototype
+Object.setPrototypeOf(screen, EventEmitter.prototype)
 
 module.exports = screen

+ 1 - 1
lib/browser/api/session.js

@@ -27,7 +27,7 @@ Object.defineProperty(exports, 'defaultSession', {
 
 var wrapSession = function (session) {
   // session is an EventEmitter.
-  session.__proto__ = EventEmitter.prototype
+  Object.setPrototypeOf(session, EventEmitter.prototype)
 }
 
 bindings._setWrapSession(wrapSession)

+ 1 - 1
lib/browser/api/tray.js

@@ -2,7 +2,7 @@ const deprecate = require('electron').deprecate
 const EventEmitter = require('events').EventEmitter
 const Tray = process.atomBinding('tray').Tray
 
-Tray.prototype.__proto__ = EventEmitter.prototype
+Object.setPrototypeOf(Tray.prototype, EventEmitter.prototype)
 
 Tray.prototype._init = function () {
   // Deprecated.

+ 2 - 2
lib/browser/api/web-contents.js

@@ -66,7 +66,7 @@ const webFrameMethods = [
 let wrapWebContents = function (webContents) {
   // webContents is an EventEmitter.
   var controller, method, name, ref1
-  webContents.__proto__ = EventEmitter.prototype
+  Object.setPrototypeOf(webContents, EventEmitter.prototype)
 
   // Every remote callback from renderer process would add a listenter to the
   // render-view-deleted event, so ignore the listenters warning.
@@ -217,7 +217,7 @@ let wrapWebContents = function (webContents) {
 // Wrapper for native class.
 let wrapDebugger = function (webContentsDebugger) {
   // debugger is an EventEmitter.
-  webContentsDebugger.__proto__ = EventEmitter.prototype
+  Object.setPrototypeOf(webContentsDebugger, EventEmitter.prototype)
 }
 
 binding._setWrapWebContents(wrapWebContents)

+ 1 - 1
lib/renderer/api/web-frame.js

@@ -6,7 +6,7 @@ const EventEmitter = require('events').EventEmitter
 const webFrame = process.atomBinding('web_frame').webFrame
 
 // webFrame is an EventEmitter.
-webFrame.__proto__ = EventEmitter.prototype
+Object.setPrototypeOf(webFrame, EventEmitter.prototype)
 
 // Lots of webview would subscribe to webFrame's events.
 webFrame.setMaxListeners(0)