diff --git a/lib/traverse.js b/lib/traverse.js index 9388e95..c16938a 100644 --- a/lib/traverse.js +++ b/lib/traverse.js @@ -82,7 +82,10 @@ function Traverse (refObj) { state.notLeaf = !state.isLeaf; state.notRoot = !state.isRoot; - f.call(state, node); + // use return values to update if defined + var ret = f.call(state, node); + if (ret !== undefined) state.update(ret); + if (typeof state.node == 'object' && state.node !== null && !state.circular) { parents.push(state);