Skip to content

Commit

Permalink
[walker] Don't visit nodes multiple times in full / fullAncestor walks
Browse files Browse the repository at this point in the history
Issue #592
  • Loading branch information
marijnh committed Oct 6, 2017
1 parent bd728e8 commit 89ca0d0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/walk/index.js
Expand Up @@ -72,7 +72,7 @@ export function full(node, callback, base, state, override) {
;(function c(node, st, override) {
let type = override || node.type
base[type](node, st, c)
callback(node, st, type)
if (!override) callback(node, st, type)
})(node, state, override)
}

Expand All @@ -86,7 +86,7 @@ export function fullAncestor(node, callback, base, state) {
let isNew = node != ancestors[ancestors.length - 1]
if (isNew) ancestors.push(node)
base[type](node, st, c)
callback(node, st || ancestors, ancestors, type)
if (!override) callback(node, st || ancestors, ancestors, type)
if (isNew) ancestors.pop()
})(node, state)
}
Expand Down

0 comments on commit 89ca0d0

Please sign in to comment.