From 8a834b338632c37cabf44174825a05d7d8fdc570 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Wed, 17 Jun 2009 18:52:55 +1000 Subject: [PATCH] Refactor isFormElemFocused and rename isInputElemFocused. --- common/content/events.js | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/common/content/events.js b/common/content/events.js index b76eb7c1..7a0e7a4e 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -458,30 +458,12 @@ function Events() //{{{ code_key[60] = "lt"; } - function isFormElemFocused() + function isInputElemFocused() { let elem = liberator.focus; - if (elem == null) - return false; - - try - { // sometimes the elem doesn't have .localName - let tagname = elem.localName.toLowerCase(); - let type = elem.type.toLowerCase(); - - if ((tagname == "input" && (type != "image")) || - tagname == "textarea" || - // tagName == "SELECT" || - // tagName == "BUTTON" || - tagname == "isindex") // isindex is a deprecated one-line input box - return true; - } - catch (e) - { - // FIXME: do nothing? - } - - return false; + return ((elem instanceof HTMLInputElement && !/image/.test(elem.type)) || + elem instanceof HTMLTextAreaElement || + elem instanceof HTMLIsIndexElement) } function triggerLoadAutocmd(name, doc) @@ -1659,7 +1641,7 @@ function Events() //{{{ // this is need for sites like msn.com which focus the input field on keydown onKeyUpOrDown: function (event) { - if (modes.passNextKey ^ modes.passAllKeys || isFormElemFocused()) + if (modes.passNextKey ^ modes.passAllKeys || isInputElemFocused()) return; event.stopPropagation();