💄 Use spread operator instead of arguments object

This commit is contained in:
Steve Kinney 2016-05-14 12:26:53 -04:00
parent 236810a923
commit fd9c9c3be7

View file

@ -50,13 +50,13 @@ BrowserWindow.prototype._init = function () {
if (!event.defaultPrevented) this.setTitle(title) if (!event.defaultPrevented) this.setTitle(title)
}) })
// Sometimes the webContents doesn't get focus when window is shown, so we // Sometimes the webContents doesn't get focus when window is shown, so we
// have to force focusing on webContents in this case. The safest way is to // have to force focusing on webContents in this case. The safest way is to
// focus it when we first start to load URL, if we do it earlier it won't // focus it when we first start to load URL, if we do it earlier it won't
// have effect, if we do it later we might move focus in the page. // have effect, if we do it later we might move focus in the page.
// //
// Though this hack is only needed on OS X when the app is launched from // Though this hack is only needed on OS X when the app is launched from
// Finder, we still do it on all platforms in case of other bugs we don't // Finder, we still do it on all platforms in case of other bugs we don't
// know. // know.
this.webContents.once('load-url', function () { this.webContents.once('load-url', function () {
this.focus() this.focus()
@ -79,7 +79,7 @@ BrowserWindow.prototype._init = function () {
this.webContents.send('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', isVisible ? 'visible' : 'hidden') this.webContents.send('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', isVisible ? 'visible' : 'hidden')
} }
} }
const visibilityEvents = ['show', 'hide', 'minimize', 'maximize', 'restore'] const visibilityEvents = ['show', 'hide', 'minimize', 'maximize', 'restore']
for (let event of visibilityEvents) { for (let event of visibilityEvents) {
this.on(event, visibilityChanged) this.on(event, visibilityChanged)
@ -101,6 +101,7 @@ BrowserWindow.getFocusedWindow = () => {
for (let window of BrowserWindow.getAllWindows()) { for (let window of BrowserWindow.getAllWindows()) {
if (window.isFocused()) return window if (window.isFocused()) return window
} }
return null
} }
BrowserWindow.fromWebContents = (webContents) => { BrowserWindow.fromWebContents = (webContents) => {
@ -118,20 +119,20 @@ BrowserWindow.fromDevToolsWebContents = (webContents) => {
// Helpers. // Helpers.
Object.assign(BrowserWindow.prototype, { Object.assign(BrowserWindow.prototype, {
loadURL () { loadURL (...args) {
return this.webContents.loadURL.apply(this.webContents, arguments) return this.webContents.loadURL.apply(this.webContents, args)
}, },
getURL () { getURL (...args) {
return this.webContents.getURL() return this.webContents.getURL()
}, },
reload () { reload (...args) {
return this.webContents.reload.apply(this.webContents, arguments) return this.webContents.reload.apply(this.webContents, args)
}, },
send () { send (...args) {
return this.webContents.send.apply(this.webContents, arguments) return this.webContents.send.apply(this.webContents, args)
}, },
openDevTools () { openDevTools (...args) {
return this.webContents.openDevTools.apply(this.webContents, arguments) return this.webContents.openDevTools.apply(this.webContents, args)
}, },
closeDevTools () { closeDevTools () {
return this.webContents.closeDevTools() return this.webContents.closeDevTools()
@ -145,8 +146,8 @@ Object.assign(BrowserWindow.prototype, {
toggleDevTools () { toggleDevTools () {
return this.webContents.toggleDevTools() return this.webContents.toggleDevTools()
}, },
inspectElement () { inspectElement (...args) {
return this.webContents.inspectElement.apply(this.webContents, arguments) return this.webContents.inspectElement.apply(this.webContents, args)
}, },
inspectServiceWorker () { inspectServiceWorker () {
return this.webContents.inspectServiceWorker() return this.webContents.inspectServiceWorker()