All native objects have prototype now
This commit is contained in:
parent
8cd4612fe0
commit
6e0cde5b24
9 changed files with 12 additions and 12 deletions
|
@ -10,7 +10,7 @@ const electron = require('electron')
|
||||||
const {deprecate, Menu} = electron
|
const {deprecate, Menu} = electron
|
||||||
const {EventEmitter} = require('events')
|
const {EventEmitter} = require('events')
|
||||||
|
|
||||||
Object.setPrototypeOf(app, EventEmitter.prototype)
|
Object.setPrototypeOf(app.__proto__, EventEmitter.prototype)
|
||||||
|
|
||||||
let appPath = null
|
let appPath = null
|
||||||
|
|
||||||
|
@ -78,5 +78,5 @@ for (let name of events) {
|
||||||
// Wrappers for native classes.
|
// Wrappers for native classes.
|
||||||
process.atomBinding('download_item')._setWrapDownloadItem((downloadItem) => {
|
process.atomBinding('download_item')._setWrapDownloadItem((downloadItem) => {
|
||||||
// downloadItem is an EventEmitter.
|
// downloadItem is an EventEmitter.
|
||||||
Object.setPrototypeOf(downloadItem, EventEmitter.prototype)
|
Object.setPrototypeOf(downloadItem.__proto__, EventEmitter.prototype)
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const EventEmitter = require('events').EventEmitter
|
const EventEmitter = require('events').EventEmitter
|
||||||
const autoUpdater = process.atomBinding('auto_updater').autoUpdater
|
const autoUpdater = process.atomBinding('auto_updater').autoUpdater
|
||||||
|
|
||||||
Object.setPrototypeOf(autoUpdater, EventEmitter.prototype)
|
Object.setPrototypeOf(autoUpdater.__proto__, EventEmitter.prototype)
|
||||||
|
|
||||||
module.exports = autoUpdater
|
module.exports = autoUpdater
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const {EventEmitter} = require('events')
|
const {EventEmitter} = require('events')
|
||||||
const {powerMonitor} = process.atomBinding('power_monitor')
|
const {powerMonitor} = process.atomBinding('power_monitor')
|
||||||
|
|
||||||
Object.setPrototypeOf(powerMonitor, EventEmitter.prototype)
|
Object.setPrototypeOf(powerMonitor.__proto__, EventEmitter.prototype)
|
||||||
|
|
||||||
module.exports = powerMonitor
|
module.exports = powerMonitor
|
||||||
|
|
|
@ -9,7 +9,7 @@ Object.setPrototypeOf(module.exports, new Proxy({}, {
|
||||||
if (!app.isReady()) return
|
if (!app.isReady()) return
|
||||||
|
|
||||||
const protocol = session.defaultSession.protocol
|
const protocol = session.defaultSession.protocol
|
||||||
if (!protocol.hasOwnProperty(property)) return
|
if (!protocol.__proto__.hasOwnProperty(property)) return
|
||||||
|
|
||||||
// Returning a native function directly would throw error.
|
// Returning a native function directly would throw error.
|
||||||
return (...args) => protocol[property](...args)
|
return (...args) => protocol[property](...args)
|
||||||
|
@ -18,7 +18,7 @@ Object.setPrototypeOf(module.exports, new Proxy({}, {
|
||||||
ownKeys () {
|
ownKeys () {
|
||||||
if (!app.isReady()) return []
|
if (!app.isReady()) return []
|
||||||
|
|
||||||
return Object.getOwnPropertyNames(session.defaultSession.protocol)
|
return Object.getOwnPropertyNames(session.defaultSession.protocol.__proto__)
|
||||||
},
|
},
|
||||||
|
|
||||||
getOwnPropertyDescriptor (target) {
|
getOwnPropertyDescriptor (target) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const {EventEmitter} = require('events')
|
const {EventEmitter} = require('events')
|
||||||
const {screen} = process.atomBinding('screen')
|
const {screen} = process.atomBinding('screen')
|
||||||
|
|
||||||
Object.setPrototypeOf(screen, EventEmitter.prototype)
|
Object.setPrototypeOf(screen.__proto__, EventEmitter.prototype)
|
||||||
|
|
||||||
module.exports = screen
|
module.exports = screen
|
||||||
|
|
|
@ -17,6 +17,6 @@ Object.defineProperties(exports, {
|
||||||
// Wraps native Session class.
|
// Wraps native Session class.
|
||||||
_setWrapSession(function (session) {
|
_setWrapSession(function (session) {
|
||||||
// Session is an EventEmitter.
|
// Session is an EventEmitter.
|
||||||
Object.setPrototypeOf(session, EventEmitter.prototype)
|
Object.setPrototypeOf(session.__proto__, EventEmitter.prototype)
|
||||||
app.emit('session-created', session)
|
app.emit('session-created', session)
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const {EventEmitter} = require('events')
|
const {EventEmitter} = require('events')
|
||||||
const {systemPreferences} = process.atomBinding('system_preferences')
|
const {systemPreferences} = process.atomBinding('system_preferences')
|
||||||
|
|
||||||
Object.setPrototypeOf(systemPreferences, EventEmitter.prototype)
|
Object.setPrototypeOf(systemPreferences.__proto__, EventEmitter.prototype)
|
||||||
|
|
||||||
module.exports = systemPreferences
|
module.exports = systemPreferences
|
||||||
|
|
|
@ -97,7 +97,7 @@ const webFrameMethodsWithResult = [
|
||||||
// Add JavaScript wrappers for WebContents class.
|
// Add JavaScript wrappers for WebContents class.
|
||||||
const wrapWebContents = function (webContents) {
|
const wrapWebContents = function (webContents) {
|
||||||
// webContents is an EventEmitter.
|
// 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
|
// Every remote callback from renderer process would add a listenter to the
|
||||||
// render-view-deleted event, so ignore the listenters warning.
|
// render-view-deleted event, so ignore the listenters warning.
|
||||||
|
@ -252,7 +252,7 @@ binding._setWrapWebContents(wrapWebContents)
|
||||||
// Add JavaScript wrappers for Debugger class.
|
// Add JavaScript wrappers for Debugger class.
|
||||||
const wrapDebugger = function (webContentsDebugger) {
|
const wrapDebugger = function (webContentsDebugger) {
|
||||||
// debugger is an EventEmitter.
|
// debugger is an EventEmitter.
|
||||||
Object.setPrototypeOf(webContentsDebugger, EventEmitter.prototype)
|
Object.setPrototypeOf(webContentsDebugger.__proto__, EventEmitter.prototype)
|
||||||
}
|
}
|
||||||
|
|
||||||
debuggerBinding._setWrapDebugger(wrapDebugger)
|
debuggerBinding._setWrapDebugger(wrapDebugger)
|
||||||
|
|
|
@ -5,7 +5,7 @@ const EventEmitter = require('events').EventEmitter
|
||||||
const webFrame = process.atomBinding('web_frame').webFrame
|
const webFrame = process.atomBinding('web_frame').webFrame
|
||||||
|
|
||||||
// webFrame is an EventEmitter.
|
// webFrame is an EventEmitter.
|
||||||
Object.setPrototypeOf(webFrame, EventEmitter.prototype)
|
Object.setPrototypeOf(webFrame.__proto__, EventEmitter.prototype)
|
||||||
|
|
||||||
// Lots of webview would subscribe to webFrame's events.
|
// Lots of webview would subscribe to webFrame's events.
|
||||||
webFrame.setMaxListeners(0)
|
webFrame.setMaxListeners(0)
|
||||||
|
|
Loading…
Reference in a new issue