зеркало из https://github.com/electron/electron.git
All native objects have prototype now
This commit is contained in:
Родитель
8cd4612fe0
Коммит
6e0cde5b24
|
@ -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)
|
||||
})
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Загрузка…
Ссылка в новой задаче