aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts
diff options
context:
space:
mode:
authormrmr19932014-12-20 16:18:28 +0000
committermrmr19932014-12-20 19:38:01 +0000
commit3a688f754ebd647ce56b33d18c5744759c5efe95 (patch)
tree745370277b71d94214f6b082e1fa4cdb1bfa4d11 /content_scripts
parent1059f98d5c9a552b2fa3fbcdddc7e44d0676056e (diff)
downloadvimium-3a688f754ebd647ce56b33d18c5744759c5efe95.tar.bz2
Use ||= to not ignore some clickable elements, no negative tabindex
Elements with `tabindex="n"` for parseInt(n) < 0 cannot be selected by pressing the tab key, according to the spec. If we have no other reason to suspect that the element is clickable, we may as well ignore them.
Diffstat (limited to 'content_scripts')
-rw-r--r--content_scripts/link_hints.coffee15
1 files changed, 8 insertions, 7 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee
index fa7fa937..9eb7b87c 100644
--- a/content_scripts/link_hints.coffee
+++ b/content_scripts/link_hints.coffee
@@ -176,18 +176,19 @@ LinkHints =
when "a"
isClickable = true
when "textarea"
- isClickable = not element.disabled and not element.readOnly
+ isClickable ||= not element.disabled and not element.readOnly
when "input"
- unless element.getAttribute("type")?.toLowerCase() == "hidden" or
- element.disabled or
- (element.readOnly and DomUtils.isSelectable element)
- isClickable = true
+ isClickable ||= not (element.getAttribute("type")?.toLowerCase() == "hidden" or
+ element.disabled or
+ (element.readOnly and DomUtils.isSelectable element))
when "button", "select"
- isClickable = true unless element.disabled
+ isClickable ||= not element.disabled
# Elements with tabindex are sometimes useful, but usually not. We can treat them as second class
# citizens when it improves UX, so take special note of them.
- if element.hasAttribute("tabindex") and not isClickable
+ tabIndexValue = element.getAttribute("tabindex")
+ tabIndex = if tabIndexValue == "" then 0 else parseInt tabIndexValue
+ unless isClickable or isNaN(tabIndex) or tabIndex < 0
isClickable = onlyHasTabIndex = true
continue unless isClickable # If the element isn't clickable, do nothing.