main.js: fix empty window opened in some cases (#5146)

Fixes the following problem:

1. Don't have any article selected (easiest by clicking on "main stream" or a category)
2. Press space
3. A blank window is opened, but since there's no link nothing else happens.
This commit is contained in:
Frans de Jonge
2023-02-25 12:32:59 +01:00
committed by GitHub
parent 859c48383a
commit e56ecf79f6

View File

@@ -1013,11 +1013,13 @@ function init_shortcuts() {
}
const link_go_website = document.querySelector('.flux.current a.go_website');
const newWindow = window.open();
if (link_go_website && newWindow) {
newWindow.opener = null;
newWindow.location = link_go_website.href;
ev.preventDefault();
if (link_go_website) {
const newWindow = window.open();
if (newWindow) {
newWindow.opener = null;
newWindow.location = link_go_website.href;
ev.preventDefault();
}
}
return;
}