aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content_scripts/link_hints.coffee29
1 files changed, 16 insertions, 13 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee
index ba550c04..8e106b0f 100644
--- a/content_scripts/link_hints.coffee
+++ b/content_scripts/link_hints.coffee
@@ -167,19 +167,22 @@ class LinkHintsMode
element.getAttribute("aria-disabled")?.toLowerCase() in ["", "true"])
return [] # This element should never have a link hint.
- # Check for AngularJS listeners on the element. These are becoming increasingly preferred instead of
- # Javascript's native onclick listeners.
- ngPrefixes = ['', 'data-', 'x-']
- ngSeparators = ['-', ':', '_']
- hasNgClick = () ->
- for prefix in ngPrefixes
- for separator in ngSeparators
- attr = "#{prefix}ng#{separator}click"
- if element.hasAttribute attr
- return true
- return false
-
- isClickable ||= hasNgClick()
+ # Check for AngularJS listeners on the element.
+ @checkForAngularJs ?= do ->
+ angularElements = document.getElementsByClassName "ng-scope"
+ if angularElements.length == 0
+ -> false
+ else
+ ngAttributes = []
+ for prefix in [ '', 'data-', 'x-' ]
+ for separator in [ '-', ':', '_' ]
+ ngAttributes.push "#{prefix}ng#{separator}click"
+ (element) ->
+ for attribute in ngAttributes
+ return true if element.hasAttribute attribute
+ false
+
+ isClickable ||= @checkForAngularJs element
# Check for attributes that make an element clickable regardless of its tagName.
if (element.hasAttribute("onclick") or