From 7917647ccad6712118b08cd86e3b4a6dda763ae3 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Wed, 29 Apr 2015 10:41:48 +0100 Subject: Use innerHTML instead of contentText. If we use contentText, then it is possible for a child and its to have exactly the same content text, in which case it is arbitrary as to which is sorted first, hence which we choose (where we should be choosing the child). Using innerHTML instead, we guess that even if the contentText lengths are the same, the innerHTML of the parent will be longer (since it contains that of the child). --- content_scripts/link_hints.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'content_scripts') diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index a5be6c57..3cebac4c 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -64,8 +64,8 @@ LinkHints = # When using text filtering, we sort the elements such that we visit descendants before their ancestors. # This allows us to exclude the text used for matching descendants from that used for matching their # ancestors. - textLength = (el) -> el.element.textContent?.length ? 0 - elements.sort (a,b) -> textLength(a) - textLength b + length = (el) -> el.element.innerHTML?.length ? 0 + elements.sort (a,b) -> length(a) - length b hintMarkers = (@createMarkerFor(el) for el in elements) @getMarkerMatcher().fillInMarkers(hintMarkers) -- cgit v1.2.3