diff --git a/lib/browser/guest-view-manager.js b/lib/browser/guest-view-manager.js index 9fffb745ac..a0bc751813 100644 --- a/lib/browser/guest-view-manager.js +++ b/lib/browser/guest-view-manager.js @@ -4,9 +4,9 @@ const ipcMain = require('electron').ipcMain const webContents = require('electron').webContents // Doesn't exist in early initialization. -var webViewManager = null +let webViewManager = null -var supportedWebViewEvents = [ +const supportedWebViewEvents = [ 'load-commit', 'did-finish-load', 'did-fail-load', @@ -40,23 +40,23 @@ var supportedWebViewEvents = [ 'update-target-url' ] -var nextInstanceId = 0 -var guestInstances = {} -var embedderElementsMap = {} -var reverseEmbedderElementsMap = {} +let nextInstanceId = 0 +const guestInstances = {} +const embedderElementsMap = {} +const reverseEmbedderElementsMap = {} // Moves the last element of array to the first one. -var moveLastToFirst = function (list) { +const moveLastToFirst = function (list) { return list.unshift(list.pop()) } // Generate guestInstanceId. -var getNextInstanceId = function () { +const getNextInstanceId = function () { return ++nextInstanceId } // Create a new guest instance. -var createGuest = function (embedder, params) { +const createGuest = function (embedder, params) { if (webViewManager == null) { webViewManager = process.atomBinding('web_view_manager') } @@ -98,7 +98,7 @@ var createGuest = function (embedder, params) { // Init guest web view after attached. guest.once('did-attach', function () { - var opts + let opts params = this.attachParams delete this.attachParams this.viewInstanceId = params.instanceId @@ -154,8 +154,8 @@ var createGuest = function (embedder, params) { } // Attach the guest to an element of embedder. -var attachGuest = function (embedder, elementInstanceId, guestInstanceId, params) { - var guest, key, oldGuestInstanceId, ref1, webPreferences +const attachGuest = function (embedder, elementInstanceId, guestInstanceId, params) { + let guest, key, oldGuestInstanceId, ref1, webPreferences guest = guestInstances[guestInstanceId].guest // Destroy the old guest when attaching. @@ -190,12 +190,12 @@ var attachGuest = function (embedder, elementInstanceId, guestInstanceId, params } // Destroy an existing guest instance. -var destroyGuest = function (embedder, id) { - var key +const destroyGuest = function (embedder, id) { webViewManager.removeGuest(embedder, id) guestInstances[id].guest.destroy() delete guestInstances[id] - key = reverseEmbedderElementsMap[id] + + const key = reverseEmbedderElementsMap[id] if (key != null) { delete reverseEmbedderElementsMap[id] return delete embedderElementsMap[key] @@ -215,18 +215,18 @@ ipcMain.on('ELECTRON_GUEST_VIEW_MANAGER_DESTROY_GUEST', function (event, id) { }) ipcMain.on('ELECTRON_GUEST_VIEW_MANAGER_SET_SIZE', function (event, id, params) { - var ref1 - return (ref1 = guestInstances[id]) != null ? ref1.guest.setSize(params) : void 0 + const guestInstance = guestInstances[id] + return guestInstance != null ? guestInstance.guest.setSize(params) : void 0 }) // Returns WebContents from its guest id. exports.getGuest = function (id) { - var ref1 - return (ref1 = guestInstances[id]) != null ? ref1.guest : void 0 + const guestInstance = guestInstances[id] + return guestInstance != null ? guestInstance.guest : void 0 } // Returns the embedder of the guest. exports.getEmbedder = function (id) { - var ref1 - return (ref1 = guestInstances[id]) != null ? ref1.embedder : void 0 + const guestInstance = guestInstances[id] + return guestInstance != null ? guestInstance.embedder : void 0 }