standardize by hand
This commit is contained in:
parent
cfdfdc8ccc
commit
e6698102c9
13 changed files with 34 additions and 33 deletions
|
@ -87,7 +87,7 @@ let wrapWebContents = function (webContents) {
|
|||
method = ref1[name]
|
||||
if (method instanceof Function) {
|
||||
(function (name, method) {
|
||||
return webContents[name] = function () {
|
||||
webContents[name] = function () {
|
||||
return method.apply(controller, arguments)
|
||||
}
|
||||
})(name, method)
|
||||
|
@ -104,8 +104,7 @@ let wrapWebContents = function (webContents) {
|
|||
const asyncWebFrameMethods = function (requestId, method, callback, ...args) {
|
||||
this.send('ELECTRON_INTERNAL_RENDERER_ASYNC_WEB_FRAME_METHOD', requestId, method, args)
|
||||
ipcMain.once(`ELECTRON_INTERNAL_BROWSER_ASYNC_WEB_FRAME_RESPONSE_${requestId}`, function (event, result) {
|
||||
if (callback)
|
||||
callback(result)
|
||||
if (callback) callback(result)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -117,10 +116,11 @@ let wrapWebContents = function (webContents) {
|
|||
callback = hasUserGesture
|
||||
hasUserGesture = false
|
||||
}
|
||||
if (this.getURL() && !this.isLoading())
|
||||
if (this.getURL() && !this.isLoading()) {
|
||||
return asyncWebFrameMethods.call(this, requestId, 'executeJavaScript', callback, code, hasUserGesture)
|
||||
else
|
||||
} else {
|
||||
return this.once('did-finish-load', asyncWebFrameMethods.bind(this, requestId, 'executeJavaScript', callback, code, hasUserGesture))
|
||||
}
|
||||
}
|
||||
|
||||
// Dispatch IPC messages to the ipc module.
|
||||
|
@ -128,11 +128,14 @@ let wrapWebContents = function (webContents) {
|
|||
return ipcMain.emit.apply(ipcMain, [channel, event].concat(args))
|
||||
})
|
||||
webContents.on('ipc-message-sync', function (event, [channel, ...args]) {
|
||||
/* eslint-disable */
|
||||
// standard complains: Getter is not present
|
||||
Object.defineProperty(event, 'returnValue', {
|
||||
set: function (value) {
|
||||
return event.sendReply(JSON.stringify(value))
|
||||
}
|
||||
})
|
||||
/* eslint-enable */
|
||||
return ipcMain.emit.apply(ipcMain, [channel, event].concat(args))
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue