Skip to content

Commit

Permalink
Always set wrapper.href if wrapper.type == 'link'
Browse files Browse the repository at this point in the history
  • Loading branch information
lydell committed Dec 2, 2015
1 parent 778e1a6 commit 1dde48c
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions extension/lib/commands-frame.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,25 @@ helper_follow = ({id, combine = true}, matcher, {vim}) ->
length = vim.state.markerElements.push(element)
wrapper = {type, semantic, shape, elementIndex: length - 1}

# Combine links with the same href.
if combine and wrapper.type == 'link' and
# If the element has an 'onclick' attribute we cannot be sure that all
# links with this href actually do the same thing. On some pages, such as
# startpage.com, actual proper links have the 'onclick' attribute, so we
# can’t exclude such links in `utils.isProperLink`.
not element.hasAttribute('onclick')
if wrapper.type == 'link'
{href} = element
wrapper.href = href
if href of hrefs
parent = hrefs[href]
wrapper.parentIndex = parent.elementIndex
parent.shape.area += wrapper.shape.area
parent.numChildren++
else
wrapper.numChildren = 0
hrefs[href] = wrapper

# Combine links with the same href.
if combine and wrapper.type == 'link' and
# If the element has an 'onclick' attribute we cannot be sure that all
# links with this href actually do the same thing. On some pages, such
# as startpage.com, actual proper links have the 'onclick' attribute,
# so we can’t exclude such links in `utils.isProperLink`.
not element.hasAttribute('onclick')
if href of hrefs
parent = hrefs[href]
wrapper.parentIndex = parent.elementIndex
parent.shape.area += wrapper.shape.area
parent.numChildren++
else
wrapper.numChildren = 0
hrefs[href] = wrapper

return wrapper

Expand Down

0 comments on commit 1dde48c

Please sign in to comment.