2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2024-11-11 07:41:04 +00:00

Fix #616 - Only override the default window opening behavior when necessary (#620)

As part of #591, all window creation was routed through a createNewWindow function.  That change introduced the regression reported in #616 in which popup windows could not communicate with their parent windows. This change reverts that behavior for windows opened via JavaScript (that aren't being opened as tabs and aren't being opened in external browsers), thereby fixing the reported regression.
This commit is contained in:
David Kramer 2018-05-26 19:50:36 -07:00 committed by Ronan Jouchet
parent 16aae0a937
commit 587d615085

View File

@ -210,22 +210,30 @@ function createMainWindow(inpOptions, onAppQuit, setDockBadge) {
};
const onNewWindow = (event, urlToGo, _, disposition) => {
const preventDefault = (newGuest) => {
event.preventDefault();
if (newGuest) {
// eslint-disable-next-line no-param-reassign
event.newGuest = newGuest;
}
};
if (nativeTabsSupported()) {
if (disposition === 'background-tab') {
createNewTab(urlToGo, false);
const newTab = createNewTab(urlToGo, false);
preventDefault(newTab);
return;
} else if (disposition === 'foreground-tab') {
createNewTab(urlToGo, true);
const newTab = createNewTab(urlToGo, true);
preventDefault(newTab);
return;
}
}
if (!linkIsInternal(options.targetUrl, urlToGo, options.internalUrls)) {
shell.openExternal(urlToGo);
preventDefault();
// eslint-disable-next-line no-useless-return
return;
}
// eslint-disable-next-line no-param-reassign
event.newGuest = createNewWindow(urlToGo);
};
const sendParamsOnDidFinishLoad = (window) => {