aboutsummaryrefslogtreecommitdiff
path: root/p/scripts
diff options
context:
space:
mode:
authorGravatar Frans de Jonge <frans@clevercast.com> 2023-02-25 12:32:59 +0100
committerGravatar GitHub <noreply@github.com> 2023-02-25 12:32:59 +0100
commite56ecf79f65b12ebaa600c961ffa2aab40cebcba (patch)
treea170e0bd70bfe5201984beecc089d859550061c3 /p/scripts
parent859c48383a229db43cf50ca64b09149bab0e3da4 (diff)
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.
Diffstat (limited to 'p/scripts')
-rw-r--r--p/scripts/main.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/p/scripts/main.js b/p/scripts/main.js
index 15db36cbe..bca6c2407 100644
--- a/p/scripts/main.js
+++ b/p/scripts/main.js
@@ -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;
}