diff options
| author | jez | 2011-05-16 11:21:35 -0400 |
|---|---|---|
| committer | jez | 2011-05-16 12:55:37 -0400 |
| commit | b63c810ef6e18c736579e7844fba56edcd7590f6 (patch) | |
| tree | 6c251993f3fb158535bb84df71bbabdcb66ff188 /vimiumFrontend.js | |
| parent | 3f51762563e030679216975c76634fb0014c0812 (diff) | |
| download | vimium-b63c810ef6e18c736579e7844fba56edcd7590f6.tar.bz2 | |
Don't enter insert mode when clicking on radio buttons and checkboxes.
This closes issue #149.
Tighten up the check for contentEditable as well -- isContentEditable covers the
case where editability is inherited. See
http://www.w3.org/TR/html5/editing.html#contenteditable for more details.
Diffstat (limited to 'vimiumFrontend.js')
| -rw-r--r-- | vimiumFrontend.js | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/vimiumFrontend.js b/vimiumFrontend.js index 2ac7c32c..de21c682 100644 --- a/vimiumFrontend.js +++ b/vimiumFrontend.js @@ -542,14 +542,17 @@ function isEmbed(element) { return ["embed", "object"].indexOf(element.nodeName. * Input or text elements are considered focusable and able to receieve their own keyboard events, * and will enter enter mode if focused. Also note that the "contentEditable" attribute can be set on * any element which makes it a rich text editor, like the notes on jjot.com. - * Note: we used to discriminate for text-only inputs, but this is not accurate since all input fields - * can be controlled via the keyboard, particuarlly SELECT combo boxes. */ function isEditable(target) { - if (target.getAttribute("contentEditable") == "true") + if (target.isContentEditable) return true; - var focusableInputs = ["input", "textarea", "select", "button"]; - return focusableInputs.indexOf(target.nodeName.toLowerCase()) >= 0; + var nodeName = target.nodeName.toLowerCase(); + // use a blacklist instead of a whitelist because new form controls are still being implemented for html5 + var noFocus = ["radio", "checkbox"]; + if (nodeName == "input" && noFocus.indexOf(target.type) == -1) + return true; + var focusableElements = ["textarea", "select"]; + return focusableElements.indexOf(nodeName) >= 0; } function enterInsertMode() { |
