diff options
| -rw-r--r-- | content_scripts/link_hints.coffee | 5 | ||||
| -rw-r--r-- | lib/dom_utils.coffee | 19 |
2 files changed, 2 insertions, 22 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index 32d67ab9..fae255c6 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -321,7 +321,6 @@ LocalHints = hint.hasHref = hint.element.href? for hint in localHints if Settings.get "filterLinkHints" - DomUtils.textContent.reset() @generateLabelMap() extend hint, @generateLinkText hint.element for hint in localHints @@ -354,14 +353,14 @@ LocalHints = linkText = element.value if not linkText and 'placeholder' of element linkText = element.placeholder - # check if there is an image embedded in the <a> tag + # Check if there is an image embedded in the <a> tag. else if (nodeName == "a" && !element.textContent.trim() && element.firstElementChild && element.firstElementChild.nodeName.toLowerCase() == "img") linkText = element.firstElementChild.alt || element.firstElementChild.title showLinkText = true if (linkText) else - linkText = DomUtils.textContent.get element + linkText = (element.textContent.trim() || element.innerHTML.trim())[...512] {linkText, showLinkText} diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index 39e1fecd..014a1f50 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -316,25 +316,6 @@ DomUtils = else sel.focusNode - # Get the text content of an element (and its descendents), but omit the text content of previously-visited - # nodes. See #1514. - # NOTE(smblott). This is currently O(N^2) (when called on N elements). An alternative would be to mark - # each node visited, and then clear the marks when we're done. - textContent: do -> - visitedNodes = null - reset: -> visitedNodes = [] - get: (element) -> - nodes = document.createTreeWalker element, NodeFilter.SHOW_TEXT - texts = - while node = nodes.nextNode() - continue unless node.nodeType == 3 - continue if node in visitedNodes - text = node.data.trim() - continue unless 0 < text.length - visitedNodes.push node - text - texts.join " " - # Get the element in the DOM hierachy that contains `element`. # If the element is rendered in a shadow DOM via a <content> element, the <content> element will be # returned, so the shadow DOM is traversed rather than passed over. |
