aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--commands.js2
-rw-r--r--vimiumFrontend.js14
2 files changed, 6 insertions, 10 deletions
diff --git a/commands.js b/commands.js
index 26ef2d34..fa24dee8 100644
--- a/commands.js
+++ b/commands.js
@@ -146,7 +146,7 @@ addCommand('copyCurrentUrl', 'Copy the current URL to the clipboard');
addCommand('enterInsertMode', 'Enter insert mode');
-addCommand('focusFirstInput', 'Focus the first text box on the page.');
+addCommand('focusFirstInput', 'Focus the first text box on the page');
addCommand('activateLinkHintsMode', 'Enter link hints mode to open links in current tab');
addCommand('activateLinkHintsModeToOpenInNewTab', 'Enter link hints mode to open links in new tab');
diff --git a/vimiumFrontend.js b/vimiumFrontend.js
index f2f5abd3..d74c6d53 100644
--- a/vimiumFrontend.js
+++ b/vimiumFrontend.js
@@ -200,15 +200,11 @@ function scrollRight() { window.scrollBy(settings["scrollStepSize"], 0); }
function focusFirstInput() {
var xpath = '//input[@type="text" or @type="search"]';
- var result = document.evaluate( xpath, document.documentElement, null,
- XPathResult.FIRST_ORDERED_NODE_TYPE, null );
-
- if ( result.singleNodeValue == null ) return;
-
- var el = document.getElementById( result.singleNodeValue.id );
- if ( el ) {
- el.focus();
- }
+ var result = document.evaluate(xpath, document.documentElement, null,
+ XPathResult.FIRST_ORDERED_NODE_TYPE, null);
+ if (!result.singleNodeValue)
+ return;
+ result.singleNodeValue.focus();
}
function reload() { window.location.reload(); }