fix up formatting in traverse
This commit is contained in:
parent
621e66e9ac
commit
d0dc972840
@ -104,17 +104,18 @@ TraversalContext.prototype.visitNode = function (obj, key, opts, scope, parent,
|
|||||||
var node = obj[key];
|
var node = obj[key];
|
||||||
|
|
||||||
// type is blacklisted
|
// type is blacklisted
|
||||||
if (opts.blacklist && opts.blacklist.indexOf(node.type) > -1)
|
if (opts.blacklist && opts.blacklist.indexOf(node.type) > -1) return;
|
||||||
return;
|
|
||||||
|
|
||||||
var ourScope = scope;
|
var ourScope = scope;
|
||||||
if (t.isScope(node))
|
if (t.isScope(node)) {
|
||||||
ourScope = new Scope(node, scope);
|
ourScope = new Scope(node, scope);
|
||||||
|
}
|
||||||
|
|
||||||
node = this.enterNode(obj, key, node, opts.enter, parent, ourScope, state);
|
node = this.enterNode(obj, key, node, opts.enter, parent, ourScope, state);
|
||||||
|
|
||||||
if (this.didSkip)
|
if (this.didSkip) {
|
||||||
return this.didStop;
|
return this.didStop;
|
||||||
|
}
|
||||||
|
|
||||||
traverseNode(node, opts, ourScope, state);
|
traverseNode(node, opts, ourScope, state);
|
||||||
this.exitNode(obj, key, node, opts.exit, parent, ourScope, state);
|
this.exitNode(obj, key, node, opts.exit, parent, ourScope, state);
|
||||||
@ -155,8 +156,9 @@ function traverseNode(node, opts, scope, state) {
|
|||||||
|
|
||||||
var context = new TraversalContext();
|
var context = new TraversalContext();
|
||||||
for (var j = 0; j < keys.length; j++) {
|
for (var j = 0; j < keys.length; j++) {
|
||||||
if (context.visit(node, keys[j], opts, scope, state))
|
if (context.visit(node, keys[j], opts, scope, state)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,13 +171,12 @@ function traverse(parent, opts, scope, state) {
|
|||||||
if (!opts.exit) opts.exit = noop;
|
if (!opts.exit) opts.exit = noop;
|
||||||
|
|
||||||
// array of nodes
|
// array of nodes
|
||||||
if (!Array.isArray(parent)) {
|
if (Array.isArray(parent)) {
|
||||||
|
for (var i = 0; i < parent.length; i++) {
|
||||||
|
traverseNode(parent[i], opts, scope, state);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
traverseNode(parent, opts, scope, state);
|
traverseNode(parent, opts, scope, state);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var i = 0; i < parent.length; i++) {
|
|
||||||
traverseNode(parent[i], opts, scope, state);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user