fix shortcircuting of unvisitable nodes

This commit is contained in:
Sebastian McKenzie 2015-05-11 01:43:18 +01:00
parent 444a64e934
commit b4ace2043a

View File

@ -11,7 +11,8 @@ export default class TraversalContext {
}
shouldVisit(node) {
return !!(this.opts.enter || this.opts[node.type] || t.VISITOR_KEYS[node.type]);
var keys = t.VISITOR_KEYS[node.type];
return !!(this.opts.enter || this.opts[node.type] || (keys && keys.length));
}
create(node, obj, key) {
@ -29,8 +30,8 @@ export default class TraversalContext {
// build up initial queue
for (let i = 0; i < nodes.length; i++) {
var node = nodes[i];
if (node && this.shouldVisit(node)) {
var self = nodes[i];
if (self && this.shouldVisit(self)) {
queue.push(this.create(node, nodes, i));
}
}