From 5e0236d9a792a2c06e4a388ebe9c3f8f2ddac225 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Tue, 10 Mar 2015 01:44:58 +1100 Subject: [PATCH] delegate node path removal to after call --- src/babel/traversal/path.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/babel/traversal/path.js b/src/babel/traversal/path.js index 8456065d2b..e7f42143d7 100644 --- a/src/babel/traversal/path.js +++ b/src/babel/traversal/path.js @@ -57,8 +57,9 @@ export default class TraversalPath { } setContext(parentPath, context, key) { - this.shouldSkip = false; - this.shouldStop = false; + this.shouldRemove = false; + this.shouldSkip = false; + this.shouldStop = false; this.parentPath = parentPath || this.parentPath; this.context = context; @@ -70,6 +71,11 @@ export default class TraversalPath { } remove() { + this.shouldRemove = true; + this.shouldSkip = true; + } + + _remove() { this._refresh(this.node, []); this.container[this.key] = null; this.flatten(); @@ -153,6 +159,10 @@ export default class TraversalPath { if (replacement) { this.node = replacement; } + + if (this.shouldRemove) { + this._remove(); + } } isBlacklisted() {