From 8292d6d8ad8319c550f9338fafac7d409a8b3b7f Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Fri, 8 May 2015 22:52:38 +0100 Subject: [PATCH] fix replacement requeue exiting too early --- src/babel/traversal/path/index.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/babel/traversal/path/index.js b/src/babel/traversal/path/index.js index 1cbe84ce59..bf9dd5688f 100644 --- a/src/babel/traversal/path/index.js +++ b/src/babel/traversal/path/index.js @@ -717,19 +717,18 @@ 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); + var previousType = this.type; if (replacement) { - var previousType = this.type; - this.replaceWith(replacement, true); - - if (previousType !== this.type) { - this.queueNode(this); - return; - } } if (this.shouldStop || this.shouldSkip || this.removed) return; + + if (replacement && previousType !== this.type) { + this.queueNode(this); + return; + } } }