Remove returns from event listeners
This commit is contained in:
parent
a2b6731bf2
commit
cc7395eea8
15 changed files with 34 additions and 36 deletions
|
@ -45,7 +45,7 @@ if (process.platform === 'darwin') {
|
|||
const events = ['login', 'certificate-error', 'select-client-certificate']
|
||||
for (let name of events) {
|
||||
app.on(name, (event, webContents, ...args) => {
|
||||
return webContents.emit.apply(webContents, [name, event].concat(args))
|
||||
webContents.emit.apply(webContents, [name, event].concat(args))
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ var spawnUpdate = function (args, detached, callback) {
|
|||
errorEmitted = false
|
||||
spawnedProcess.on('error', function (error) {
|
||||
errorEmitted = true
|
||||
return callback(error)
|
||||
callback(error)
|
||||
})
|
||||
return spawnedProcess.on('exit', function (code, signal) {
|
||||
spawnedProcess = undefined
|
||||
|
@ -72,7 +72,7 @@ var spawnUpdate = function (args, detached, callback) {
|
|||
}
|
||||
|
||||
// Success.
|
||||
return callback(null, stdout)
|
||||
callback(null, stdout)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ BrowserWindow.prototype._init = function () {
|
|||
width: 800,
|
||||
height: 600
|
||||
}
|
||||
return ipcMain.emit('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_OPEN', event, url, frameName, disposition, options)
|
||||
ipcMain.emit('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_OPEN', event, url, frameName, disposition, options)
|
||||
})
|
||||
|
||||
// window.resizeTo(...)
|
||||
|
|
|
@ -125,7 +125,7 @@ let wrapWebContents = function (webContents) {
|
|||
|
||||
// Dispatch IPC messages to the ipc module.
|
||||
webContents.on('ipc-message', function (event, [channel, ...args]) {
|
||||
return ipcMain.emit.apply(ipcMain, [channel, event].concat(args))
|
||||
ipcMain.emit.apply(ipcMain, [channel, event].concat(args))
|
||||
})
|
||||
webContents.on('ipc-message-sync', function (event, [channel, ...args]) {
|
||||
Object.defineProperty(event, 'returnValue', {
|
||||
|
@ -141,9 +141,8 @@ let wrapWebContents = function (webContents) {
|
|||
|
||||
// Handle context menu action request from pepper plugin.
|
||||
webContents.on('pepper-context-menu', function (event, params) {
|
||||
var menu
|
||||
menu = Menu.buildFromTemplate(params.menu)
|
||||
return menu.popup(params.x, params.y)
|
||||
const menu = Menu.buildFromTemplate(params.menu)
|
||||
menu.popup(params.x, params.y)
|
||||
})
|
||||
|
||||
// The devtools requests the webContents to reload.
|
||||
|
|
|
@ -28,7 +28,7 @@ ipcMain.on('ELECTRON_BROWSER_DESKTOP_CAPTURER_GET_SOURCES', function (event, cap
|
|||
|
||||
// If the WebContents is destroyed before receiving result, just remove the
|
||||
// reference from requestsQueue to make the module not send the result to it.
|
||||
return event.sender.once('destroyed', function () {
|
||||
event.sender.once('destroyed', function () {
|
||||
request.webContents = null
|
||||
})
|
||||
})
|
||||
|
|
|
@ -137,7 +137,7 @@ var createGuest = function (embedder, params) {
|
|||
// Dispatch events to embedder.
|
||||
fn = function (event) {
|
||||
return guest.on(event, function (_, ...args) {
|
||||
return embedder.send.apply(embedder, ['ELECTRON_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-' + guest.viewInstanceId, event].concat(args))
|
||||
embedder.send.apply(embedder, ['ELECTRON_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-' + guest.viewInstanceId, event].concat(args))
|
||||
})
|
||||
}
|
||||
for (j = 0, len1 = supportedWebViewEvents.length; j < len1; j++) {
|
||||
|
@ -147,12 +147,12 @@ var createGuest = function (embedder, params) {
|
|||
|
||||
// Dispatch guest's IPC messages to embedder.
|
||||
guest.on('ipc-message-host', function (_, [channel, ...args]) {
|
||||
return embedder.send.apply(embedder, ['ELECTRON_GUEST_VIEW_INTERNAL_IPC_MESSAGE-' + guest.viewInstanceId, channel].concat(args))
|
||||
embedder.send.apply(embedder, ['ELECTRON_GUEST_VIEW_INTERNAL_IPC_MESSAGE-' + guest.viewInstanceId, channel].concat(args))
|
||||
})
|
||||
|
||||
// Autosize.
|
||||
guest.on('size-changed', function (_, ...args) {
|
||||
return embedder.send.apply(embedder, ['ELECTRON_GUEST_VIEW_INTERNAL_SIZE_CHANGED-' + guest.viewInstanceId].concat(args))
|
||||
embedder.send.apply(embedder, ['ELECTRON_GUEST_VIEW_INTERNAL_SIZE_CHANGED-' + guest.viewInstanceId].concat(args))
|
||||
})
|
||||
return id
|
||||
}
|
||||
|
@ -206,15 +206,15 @@ var destroyGuest = function (embedder, id) {
|
|||
}
|
||||
|
||||
ipcMain.on('ELECTRON_GUEST_VIEW_MANAGER_CREATE_GUEST', function (event, params, requestId) {
|
||||
return event.sender.send('ELECTRON_RESPONSE_' + requestId, createGuest(event.sender, params))
|
||||
event.sender.send('ELECTRON_RESPONSE_' + requestId, createGuest(event.sender, params))
|
||||
})
|
||||
|
||||
ipcMain.on('ELECTRON_GUEST_VIEW_MANAGER_ATTACH_GUEST', function (event, elementInstanceId, guestInstanceId, params) {
|
||||
return attachGuest(event.sender, elementInstanceId, guestInstanceId, params)
|
||||
attachGuest(event.sender, elementInstanceId, guestInstanceId, params)
|
||||
})
|
||||
|
||||
ipcMain.on('ELECTRON_GUEST_VIEW_MANAGER_DESTROY_GUEST', function (event, id) {
|
||||
return destroyGuest(event.sender, id)
|
||||
destroyGuest(event.sender, id)
|
||||
})
|
||||
|
||||
ipcMain.on('ELECTRON_GUEST_VIEW_MANAGER_SET_SIZE', function (event, id, params) {
|
||||
|
|
|
@ -79,7 +79,7 @@ var createGuest = function (embedder, url, frameName, options) {
|
|||
frameToGuest[frameName] = guest
|
||||
guest.frameName = frameName
|
||||
guest.once('closed', function () {
|
||||
return delete frameToGuest[frameName]
|
||||
delete frameToGuest[frameName]
|
||||
})
|
||||
}
|
||||
return guest.id
|
||||
|
@ -98,7 +98,7 @@ ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_OPEN', function (event, url, fr
|
|||
|
||||
ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_CLOSE', function (event, guestId) {
|
||||
var ref1
|
||||
return (ref1 = BrowserWindow.fromId(guestId)) != null ? ref1.destroy() : void 0
|
||||
(ref1 = BrowserWindow.fromId(guestId)) != null ? ref1.destroy() : void 0
|
||||
})
|
||||
|
||||
ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_METHOD', function (event, guestId, method, ...args) {
|
||||
|
@ -114,11 +114,11 @@ ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', function (event,
|
|||
}
|
||||
guestContents = (ref2 = BrowserWindow.fromId(guestId)) != null ? ref2.webContents : void 0
|
||||
if ((guestContents != null ? guestContents.getURL().indexOf(targetOrigin) : void 0) === 0 || targetOrigin === '*') {
|
||||
return guestContents != null ? guestContents.send('ELECTRON_GUEST_WINDOW_POSTMESSAGE', sourceId, message, sourceOrigin) : void 0
|
||||
guestContents != null ? guestContents.send('ELECTRON_GUEST_WINDOW_POSTMESSAGE', sourceId, message, sourceOrigin) : void 0
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', function (event, guestId, method, ...args) {
|
||||
var ref1, ref2
|
||||
return (ref1 = BrowserWindow.fromId(guestId)) != null ? (ref2 = ref1.webContents) != null ? ref2[method].apply(ref2, args) : void 0 : void 0
|
||||
(ref1 = BrowserWindow.fromId(guestId)) != null ? (ref2 = ref1.webContents) != null ? ref2[method].apply(ref2, args) : void 0 : void 0
|
||||
})
|
||||
|
|
|
@ -61,14 +61,14 @@ process.on('uncaughtException', function (error) {
|
|||
dialog = require('electron').dialog
|
||||
stack = (ref = error.stack) != null ? ref : error.name + ': ' + error.message
|
||||
message = 'Uncaught Exception:\n' + stack
|
||||
return dialog.showErrorBox('A JavaScript error occurred in the main process', message)
|
||||
dialog.showErrorBox('A JavaScript error occurred in the main process', message)
|
||||
})
|
||||
|
||||
// Emit 'exit' event on quit.
|
||||
var app = require('electron').app
|
||||
|
||||
app.on('quit', function (event, exitCode) {
|
||||
return process.emit('exit', exitCode)
|
||||
process.emit('exit', exitCode)
|
||||
})
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
|
|
|
@ -273,7 +273,7 @@ ipcMain.on('ELECTRON_BROWSER_FUNCTION_CALL', function (event, id, args) {
|
|||
try {
|
||||
args = unwrapArgs(event.sender, args)
|
||||
let func = objectsRegistry.get(id)
|
||||
return callFunction(event, func, global, args)
|
||||
callFunction(event, func, global, args)
|
||||
} catch (error) {
|
||||
event.returnValue = exceptionToMeta(error)
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ ipcMain.on('ELECTRON_BROWSER_MEMBER_CALL', function (event, id, method, args) {
|
|||
try {
|
||||
args = unwrapArgs(event.sender, args)
|
||||
let obj = objectsRegistry.get(id)
|
||||
return callFunction(event, obj[method], obj, args)
|
||||
callFunction(event, obj[method], obj, args)
|
||||
} catch (error) {
|
||||
event.returnValue = exceptionToMeta(error)
|
||||
}
|
||||
|
@ -322,7 +322,7 @@ ipcMain.on('ELECTRON_BROWSER_MEMBER_GET', function (event, id, name) {
|
|||
})
|
||||
|
||||
ipcMain.on('ELECTRON_BROWSER_DEREFERENCE', function (event, id) {
|
||||
return objectsRegistry.remove(event.sender.getId(), id)
|
||||
objectsRegistry.remove(event.sender.getId(), id)
|
||||
})
|
||||
|
||||
ipcMain.on('ELECTRON_BROWSER_GUEST_WEB_CONTENTS', function (event, guestInstanceId) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue