aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Skogly2015-06-18 12:55:54 +0200
committerDaniel Skogly2015-06-18 12:55:54 +0200
commitf7c1431c1f9bbd7f40934fe32f30449cd81f99a3 (patch)
treef1f886156dddba471cd97eb1582f869989be4214
parent53e84b4800040fd573c7dce4493eb878ceb93766 (diff)
downloadvimium-f7c1431c1f9bbd7f40934fe32f30449cd81f99a3.tar.bz2
Added hasNgClick-check in getVisibleClickable
There's a fair amount of angular-sites running around, so including ngClick (with all its valid variations) seems like a good idea. I added a hasNgClick-check in the if block that checks if an element is clickable regardless of tagName.
-rw-r--r--content_scripts/link_hints.coffee15
1 files changed, 14 insertions, 1 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee
index 15af15c5..770a4639 100644
--- a/content_scripts/link_hints.coffee
+++ b/content_scripts/link_hints.coffee
@@ -166,12 +166,25 @@ class LinkHintsMode
if (element.getAttribute("aria-hidden")?.toLowerCase() in ["", "true"] or
element.getAttribute("aria-disabled")?.toLowerCase() in ["", "true"])
return [] # This element should never have a link hint.
+
+ # checks for every valid version of ng-click
+ ngPrefixes = ['', 'data-', 'x-']
+ ngSeparators = ['-', ':', '_']
+ ng = 'ng'
+ click = 'click'
+ hasNgClick: (element) ->
+ for prefix in ngPrefixes
+ for separator in ngSeparators
+ attr = prefix + ng + separator + click
+ if element.attributes.hasOwnProperty(attr)
+ return true
# Check for attributes that make an element clickable regardless of its tagName.
if (element.hasAttribute("onclick") or
element.getAttribute("role")?.toLowerCase() in ["button", "link"] or
element.getAttribute("class")?.toLowerCase().indexOf("button") >= 0 or
- element.getAttribute("contentEditable")?.toLowerCase() in ["", "contentEditable", "true"])
+ element.getAttribute("contentEditable")?.toLowerCase() in ["", "contentEditable", "true"]) or
+ hasNgClick element
isClickable = true
# Check for jsaction event listeners on the element.