From 78b72512cbbf620f58de318f44c1da853ab3bafa Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Fri, 8 May 2015 00:24:04 +0100 Subject: [PATCH] better verify the type of the new node before requeueing it and also stop current node traversal on skip --- src/babel/traversal/path/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/babel/traversal/path/index.js b/src/babel/traversal/path/index.js index 68735963d8..1988f661ff 100644 --- a/src/babel/traversal/path/index.js +++ b/src/babel/traversal/path/index.js @@ -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; } }