From d3252e0eb11a40b1abeacca290934d0fc8baeb40 Mon Sep 17 00:00:00 2001 From: Ryohei Ikegami Date: Tue, 21 Mar 2017 16:09:53 +0900 Subject: [PATCH] Reuse existing event --- lib/browser/guest-window-manager.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/browser/guest-window-manager.js b/lib/browser/guest-window-manager.js index c75e33882395..a9c9e20a36f7 100644 --- a/lib/browser/guest-window-manager.js +++ b/lib/browser/guest-window-manager.js @@ -242,18 +242,13 @@ ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_INTERNAL_WINDOW_OPEN', function (event disposition, options, additionalFeatures, postData) { options = mergeBrowserWindowOptions(event.sender, options) - const newWindowEvent = { - preventDefault: function () { - this.defaultPrevented = true - } - } - event.sender.emit('new-window', newWindowEvent, url, frameName, disposition, options, additionalFeatures) - const newGuest = newWindowEvent.newGuest - if ((event.sender.isGuest() && !event.sender.allowPopups) || newWindowEvent.defaultPrevented) { + event.sender.emit('new-window', event, url, frameName, disposition, options, additionalFeatures) + const newGuest = event.newGuest + if ((event.sender.isGuest() && !event.sender.allowPopups) || event.defaultPrevented) { if (newGuest !== undefined && newGuest !== null) { + event.defaultPrevented = false event.returnValue = setupGuest(event.sender, frameName, newGuest, options) } else { - event.preventDefault() event.returnValue = null } } else {