diff options
| author | Daniel Skogly | 2015-06-19 22:07:08 +0200 |
|---|---|---|
| committer | Daniel Skogly | 2015-06-19 22:07:08 +0200 |
| commit | 481c162aa047ab5c7169069303bcdbed73051e8d (patch) | |
| tree | a71dda699f92113873aba081a80e40a723e47a32 | |
| parent | 8c161c8e03d112f74ca4fde8981927276c1388a5 (diff) | |
| download | vimium-481c162aa047ab5c7169069303bcdbed73051e8d.tar.bz2 | |
Clarifications to ngClick check
| -rw-r--r-- | content_scripts/link_hints.coffee | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index 2f9c6af2..37758c95 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -167,25 +167,26 @@ class LinkHintsMode element.getAttribute("aria-disabled")?.toLowerCase() in ["", "true"]) return [] # This element should never have a link hint. - # checks for every valid version of ng-click + # The quite popular (http://w3techs.com/technologies/market/javascript_library/20) JavaScript framework AngularJS + # uses the proprietary click attribute "ng-click". This checks for every valid way it may occur. ngPrefixes = ['', 'data-', 'x-'] ngSeparators = ['-', ':', '_'] - ng = 'ng' - click = 'click' hasNgClick = () -> for prefix in ngPrefixes for separator in ngSeparators - attr = prefix + ng + separator + click - if element.attributes.hasOwnProperty(attr) + attr = "#{prefix}ng#{separator}click" + if element.hasAttribute(attr) return true return false + + if hasNgClick() + isClickable = 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"]) or - hasNgClick() + element.getAttribute("contentEditable")?.toLowerCase() in ["", "contentEditable", "true"]) isClickable = true # Check for jsaction event listeners on the element. |
