hints: do not execute `click` in addition to opening hints
authorPatrick Steinhardt <ps@pks.im>
Sat, 20 May 2017 16:56:18 +0000 (18:56 +0200)
committerPatrick Steinhardt <ps@pks.im>
Sat, 20 May 2017 16:56:18 +0000 (18:56 +0200)
When the element which we are about to open has a "href" attribute, we
will execute either `window.open` or set the `window.location.href`
attribute to the target's reference. But as we forgot to call `return`
here, we will also execute the code to open elements without "href"
attribute. In the case of opening a new window, we will now first open
the new window and then also set the current window's URL to the target,
which is obviously wrong.

Fix the issue by putting the excution of `click()` inside an
else-branch.

src/scripts/hints.js

index ceb86ed..4e8fd28 100644 (file)
@@ -400,8 +400,9 @@ var hints = Object.freeze((function(){
             } else {
                 window.location.href = e.getAttribute('href');
             }
+        } else {
+            window.setTimeout(function() {e.click();}, 0);
         }
-        window.setTimeout(function() {e.click();}, 0);
     }
 
     /* set focus on hint with given index valid hints array */