All native objects have prototype now

This commit is contained in:
Cheng Zhao 2016-08-02 17:12:17 +09:00
parent 8cd4612fe0
commit 6e0cde5b24
9 changed files with 12 additions and 12 deletions

View file

@ -10,7 +10,7 @@ const electron = require('electron')
const {deprecate, Menu} = electron
const {EventEmitter} = require('events')
Object.setPrototypeOf(app, EventEmitter.prototype)
Object.setPrototypeOf(app.__proto__, EventEmitter.prototype)
let appPath = null
@ -78,5 +78,5 @@ for (let name of events) {
// Wrappers for native classes.
process.atomBinding('download_item')._setWrapDownloadItem((downloadItem) => {
// downloadItem is an EventEmitter.
Object.setPrototypeOf(downloadItem, EventEmitter.prototype)
Object.setPrototypeOf(downloadItem.__proto__, EventEmitter.prototype)
})

View file

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

View file

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

View file

@ -9,7 +9,7 @@ Object.setPrototypeOf(module.exports, new Proxy({}, {
if (!app.isReady()) return
const protocol = session.defaultSession.protocol
if (!protocol.hasOwnProperty(property)) return
if (!protocol.__proto__.hasOwnProperty(property)) return
// Returning a native function directly would throw error.
return (...args) => protocol[property](...args)
@ -18,7 +18,7 @@ Object.setPrototypeOf(module.exports, new Proxy({}, {
ownKeys () {
if (!app.isReady()) return []
return Object.getOwnPropertyNames(session.defaultSession.protocol)
return Object.getOwnPropertyNames(session.defaultSession.protocol.__proto__)
},
getOwnPropertyDescriptor (target) {

View file

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

View file

@ -17,6 +17,6 @@ Object.defineProperties(exports, {
// Wraps native Session class.
_setWrapSession(function (session) {
// Session is an EventEmitter.
Object.setPrototypeOf(session, EventEmitter.prototype)
Object.setPrototypeOf(session.__proto__, EventEmitter.prototype)
app.emit('session-created', session)
})

View file

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

View file

@ -97,7 +97,7 @@ const webFrameMethodsWithResult = [
// Add JavaScript wrappers for WebContents class.
const wrapWebContents = function (webContents) {
// webContents is an EventEmitter.
Object.setPrototypeOf(webContents, EventEmitter.prototype)
Object.setPrototypeOf(webContents.__proto__, EventEmitter.prototype)
// Every remote callback from renderer process would add a listenter to the
// render-view-deleted event, so ignore the listenters warning.
@ -252,7 +252,7 @@ binding._setWrapWebContents(wrapWebContents)
// Add JavaScript wrappers for Debugger class.
const wrapDebugger = function (webContentsDebugger) {
// debugger is an EventEmitter.
Object.setPrototypeOf(webContentsDebugger, EventEmitter.prototype)
Object.setPrototypeOf(webContentsDebugger.__proto__, EventEmitter.prototype)
}
debuggerBinding._setWrapDebugger(wrapDebugger)

View file

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