better verify the type of the new node before requeueing it and also stop current node traversal on skip

This commit is contained in:
Sebastian McKenzie 2015-05-08 00:24:04 +01:00
parent 2fbb3cad9f
commit 78b72512cb

View File

@ -717,16 +717,19 @@ export default class TraversalPath {
// call the function with the params (node, parent, scope, state)
var replacement = fn.call(this, node, this.parent, this.scope, this.state);
if (replacement) {
var previousType = this.type;
this.replaceWith(replacement, true);
if (this.type !== previousType) {
if (previousType !== this.type) {
this.queueNode(this);
return;
}
}
if (this.shouldStop || this.removed) return;
if (this.shouldStop || this.shouldSkip || this.removed) return;
}
}