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; } }