mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Use spread syntax instead of function apply
This commit is contained in:
@@ -71,7 +71,7 @@ app.allowNTLMCredentialsForAllDomains = function (allow) {
|
||||
const events = ['login', 'certificate-error', 'select-client-certificate']
|
||||
for (let name of events) {
|
||||
app.on(name, (event, webContents, ...args) => {
|
||||
webContents.emit.apply(webContents, [name, event].concat(args))
|
||||
webContents.emit(name, event, ...args)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -119,19 +119,19 @@ BrowserWindow.fromDevToolsWebContents = (webContents) => {
|
||||
// Helpers.
|
||||
Object.assign(BrowserWindow.prototype, {
|
||||
loadURL (...args) {
|
||||
return this.webContents.loadURL.apply(this.webContents, args)
|
||||
return this.webContents.loadURL(...args)
|
||||
},
|
||||
getURL (...args) {
|
||||
return this.webContents.getURL()
|
||||
},
|
||||
reload (...args) {
|
||||
return this.webContents.reload.apply(this.webContents, args)
|
||||
return this.webContents.reload(...args)
|
||||
},
|
||||
send (...args) {
|
||||
return this.webContents.send.apply(this.webContents, args)
|
||||
return this.webContents.send(...args)
|
||||
},
|
||||
openDevTools (...args) {
|
||||
return this.webContents.openDevTools.apply(this.webContents, args)
|
||||
return this.webContents.openDevTools(...args)
|
||||
},
|
||||
closeDevTools () {
|
||||
return this.webContents.closeDevTools()
|
||||
@@ -146,7 +146,7 @@ Object.assign(BrowserWindow.prototype, {
|
||||
return this.webContents.toggleDevTools()
|
||||
},
|
||||
inspectElement (...args) {
|
||||
return this.webContents.inspectElement.apply(this.webContents, args)
|
||||
return this.webContents.inspectElement(...args)
|
||||
},
|
||||
inspectServiceWorker () {
|
||||
return this.webContents.inspectServiceWorker()
|
||||
@@ -155,7 +155,7 @@ Object.assign(BrowserWindow.prototype, {
|
||||
return this.webContents.showDefinitionForSelection()
|
||||
},
|
||||
capturePage (...args) {
|
||||
return this.webContents.capturePage.apply(this.webContents, args)
|
||||
return this.webContents.capturePage(...args)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ module.exports = {
|
||||
showOpenDialog: function (...args) {
|
||||
var prop, properties, value, wrappedCallback
|
||||
checkAppInitialized()
|
||||
let [window, options, callback] = parseArgs.apply(null, args)
|
||||
let [window, options, callback] = parseArgs(...args)
|
||||
if (options == null) {
|
||||
options = {
|
||||
title: 'Open',
|
||||
@@ -97,7 +97,7 @@ module.exports = {
|
||||
showSaveDialog: function (...args) {
|
||||
var wrappedCallback
|
||||
checkAppInitialized()
|
||||
let [window, options, callback] = parseArgs.apply(null, args)
|
||||
let [window, options, callback] = parseArgs(...args)
|
||||
if (options == null) {
|
||||
options = {
|
||||
title: 'Save'
|
||||
@@ -130,7 +130,7 @@ module.exports = {
|
||||
showMessageBox: function (...args) {
|
||||
var flags, i, j, len, messageBoxType, ref2, ref3, text
|
||||
checkAppInitialized()
|
||||
let [window, options, callback] = parseArgs.apply(null, args)
|
||||
let [window, options, callback] = parseArgs(...args)
|
||||
if (options == null) {
|
||||
options = {
|
||||
type: 'none'
|
||||
@@ -185,7 +185,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
showErrorBox: function (...args) {
|
||||
return binding.showErrorBox.apply(binding, args)
|
||||
return binding.showErrorBox(...args)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,13 +4,11 @@ const {ipcMain} = require('electron')
|
||||
|
||||
// The history operation in renderer is redirected to browser.
|
||||
ipcMain.on('ELECTRON_NAVIGATION_CONTROLLER', function (event, method, ...args) {
|
||||
var ref
|
||||
(ref = event.sender)[method].apply(ref, args)
|
||||
event.sender[method](...args)
|
||||
})
|
||||
|
||||
ipcMain.on('ELECTRON_SYNC_NAVIGATION_CONTROLLER', function (event, method, ...args) {
|
||||
var ref
|
||||
event.returnValue = (ref = event.sender)[method].apply(ref, args)
|
||||
event.returnValue = event.sender[method](...args)
|
||||
})
|
||||
|
||||
// JavaScript implementation of Chromium's NavigationController.
|
||||
|
||||
@@ -237,7 +237,7 @@ WebContents.prototype._init = function () {
|
||||
// Delays the page-title-updated event to next tick.
|
||||
this.on('-page-title-updated', function (...args) {
|
||||
setImmediate(() => {
|
||||
this.emit.apply(this, ['page-title-updated'].concat(args))
|
||||
this.emit('page-title-updated', ...args)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_METHOD', function (event, guest
|
||||
|
||||
const guestWindow = getGuestWindow(guestContents)
|
||||
if (guestWindow != null) {
|
||||
event.returnValue = guestWindow[method].apply(guestWindow, args)
|
||||
event.returnValue = guestWindow[method](...args)
|
||||
} else {
|
||||
event.returnValue = null
|
||||
}
|
||||
@@ -177,7 +177,7 @@ ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', function (event,
|
||||
if (guestContents == null) return
|
||||
|
||||
if (canAccessWindow(event.sender, guestContents)) {
|
||||
guestContents[method].apply(guestContents, args)
|
||||
guestContents[method](...args)
|
||||
} else {
|
||||
console.error(`Blocked ${event.sender.getURL()} from calling ${method} on its opener.`)
|
||||
}
|
||||
@@ -191,7 +191,7 @@ ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD_SYNC', function (e
|
||||
}
|
||||
|
||||
if (canAccessWindow(event.sender, guestContents)) {
|
||||
event.returnValue = guestContents[method].apply(guestContents, args)
|
||||
event.returnValue = guestContents[method](...args)
|
||||
} else {
|
||||
console.error(`Blocked ${event.sender.getURL()} from calling ${method} on its opener.`)
|
||||
event.returnValue = null
|
||||
|
||||
@@ -26,7 +26,7 @@ if (process.platform === 'win32') {
|
||||
// Redirect node's console to use our own implementations, since node can not
|
||||
// handle console output when running as GUI program.
|
||||
var consoleLog = function (...args) {
|
||||
return process.log(util.format.apply(util, args) + '\n')
|
||||
return process.log(util.format(...args) + '\n')
|
||||
}
|
||||
var streamWrite = function (chunk, encoding, callback) {
|
||||
if (Buffer.isBuffer(chunk)) {
|
||||
|
||||
@@ -45,13 +45,11 @@ class CallbacksRegistry {
|
||||
}
|
||||
|
||||
call (id, ...args) {
|
||||
var ref
|
||||
return (ref = this.get(id)).call.apply(ref, [global].concat(args))
|
||||
return this.get(id).call(global, ...args)
|
||||
}
|
||||
|
||||
apply (id, ...args) {
|
||||
var ref
|
||||
return (ref = this.get(id)).apply.apply(ref, [global].concat(args))
|
||||
return this.get(id).apply(global, ...args)
|
||||
}
|
||||
|
||||
remove (id) {
|
||||
|
||||
@@ -29,20 +29,18 @@ const electron = require('electron')
|
||||
|
||||
// Call webFrame method.
|
||||
electron.ipcRenderer.on('ELECTRON_INTERNAL_RENDERER_WEB_FRAME_METHOD', (event, method, args) => {
|
||||
electron.webFrame[method].apply(electron.webFrame, args)
|
||||
electron.webFrame[method](...args)
|
||||
})
|
||||
|
||||
electron.ipcRenderer.on('ELECTRON_INTERNAL_RENDERER_SYNC_WEB_FRAME_METHOD', (event, requestId, method, args) => {
|
||||
const result = electron.webFrame[method].apply(electron.webFrame, args)
|
||||
const result = electron.webFrame[method](...args)
|
||||
event.sender.send(`ELECTRON_INTERNAL_BROWSER_SYNC_WEB_FRAME_RESPONSE_${requestId}`, result)
|
||||
})
|
||||
|
||||
electron.ipcRenderer.on('ELECTRON_INTERNAL_RENDERER_ASYNC_WEB_FRAME_METHOD', (event, requestId, method, args) => {
|
||||
const responseCallback = function (result) {
|
||||
electron.webFrame[method](...args, function (result) {
|
||||
event.sender.send(`ELECTRON_INTERNAL_BROWSER_ASYNC_WEB_FRAME_RESPONSE_${requestId}`, result)
|
||||
}
|
||||
args.push(responseCallback)
|
||||
electron.webFrame[method].apply(electron.webFrame, args)
|
||||
})
|
||||
})
|
||||
|
||||
// Process command line arguments.
|
||||
|
||||
@@ -77,7 +77,7 @@ const BrowserWindowProxy = (function () {
|
||||
}
|
||||
|
||||
BrowserWindowProxy.prototype['eval'] = function (...args) {
|
||||
ipcRenderer.send.apply(ipcRenderer, ['ELECTRON_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', this.guestId, 'executeJavaScript'].concat(args))
|
||||
ipcRenderer.send('ELECTRON_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', this.guestId, 'executeJavaScript', ...args)
|
||||
}
|
||||
|
||||
return BrowserWindowProxy
|
||||
@@ -192,11 +192,11 @@ ipcRenderer.on('ELECTRON_GUEST_WINDOW_POSTMESSAGE', function (event, sourceId, m
|
||||
|
||||
// Forward history operations to browser.
|
||||
var sendHistoryOperation = function (...args) {
|
||||
ipcRenderer.send.apply(ipcRenderer, ['ELECTRON_NAVIGATION_CONTROLLER'].concat(args))
|
||||
ipcRenderer.send('ELECTRON_NAVIGATION_CONTROLLER', ...args)
|
||||
}
|
||||
|
||||
var getHistoryOperation = function (...args) {
|
||||
return ipcRenderer.sendSync.apply(ipcRenderer, ['ELECTRON_SYNC_NAVIGATION_CONTROLLER'].concat(args))
|
||||
return ipcRenderer.sendSync('ELECTRON_SYNC_NAVIGATION_CONTROLLER', ...args)
|
||||
}
|
||||
|
||||
window.history.back = function () {
|
||||
|
||||
@@ -46,7 +46,7 @@ var DEPRECATED_EVENTS = {
|
||||
var dispatchEvent = function (webView, eventName, eventKey, ...args) {
|
||||
var domEvent, f, i, j, len, ref1
|
||||
if (DEPRECATED_EVENTS[eventName] != null) {
|
||||
dispatchEvent.apply(null, [webView, DEPRECATED_EVENTS[eventName], eventKey].concat(args))
|
||||
dispatchEvent(webView, DEPRECATED_EVENTS[eventName], eventKey, ...args)
|
||||
}
|
||||
domEvent = new Event(eventName)
|
||||
ref1 = WEB_VIEW_EVENTS[eventKey]
|
||||
@@ -63,7 +63,7 @@ var dispatchEvent = function (webView, eventName, eventKey, ...args) {
|
||||
module.exports = {
|
||||
registerEvents: function (webView, viewInstanceId) {
|
||||
ipcRenderer.on('ELECTRON_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-' + viewInstanceId, function (event, eventName, ...args) {
|
||||
dispatchEvent.apply(null, [webView, eventName, eventName].concat(args))
|
||||
dispatchEvent(webView, eventName, eventName, ...args)
|
||||
})
|
||||
|
||||
ipcRenderer.on('ELECTRON_GUEST_VIEW_INTERNAL_IPC_MESSAGE-' + viewInstanceId, function (event, channel, ...args) {
|
||||
|
||||
@@ -407,7 +407,7 @@ var registerWebViewElement = function () {
|
||||
return function (...args) {
|
||||
const internal = v8Util.getHiddenValue(this, 'internal')
|
||||
if (internal.webContents) {
|
||||
return internal.webContents[m].apply(internal.webContents, args)
|
||||
return internal.webContents[m](...args)
|
||||
} else {
|
||||
throw new Error(`Cannot call ${m} because the webContents is unavailable. The WebView must be attached to the DOM and the dom-ready event emitted before this method can be called.`)
|
||||
}
|
||||
@@ -420,7 +420,7 @@ var registerWebViewElement = function () {
|
||||
createNonBlockHandler = function (m) {
|
||||
return function (...args) {
|
||||
const internal = v8Util.getHiddenValue(this, 'internal')
|
||||
return ipcRenderer.send.apply(ipcRenderer, ['ELECTRON_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', null, internal.guestInstanceId, m].concat(args))
|
||||
return ipcRenderer.send('ELECTRON_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', null, internal.guestInstanceId, m, ...args)
|
||||
}
|
||||
}
|
||||
for (j = 0, len1 = nonblockMethods.length; j < len1; j++) {
|
||||
|
||||
Reference in New Issue
Block a user