Fix bug replacement nodes not requeued (#5743)
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
(function () {
|
||||
let q;
|
||||
let w;
|
||||
let e;
|
||||
if (true) [q, w, e] = [1, 2, 3].map(()=>123);
|
||||
})();
|
||||
@@ -0,0 +1,17 @@
|
||||
(function () {
|
||||
var q = void 0;
|
||||
var w = void 0;
|
||||
var e = void 0;
|
||||
|
||||
if (true) {
|
||||
var _map = [1, 2, 3].map(function () {
|
||||
return 123;
|
||||
});
|
||||
|
||||
var _map2 = babelHelpers.slicedToArray(_map, 3);
|
||||
|
||||
q = _map2[0];
|
||||
w = _map2[1];
|
||||
e = _map2[2];
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["external-helpers", "transform-es2015-arrow-functions", "transform-es2015-destructuring", "transform-es2015-spread", "transform-es2015-parameters", "transform-es2015-block-scoping", "transform-object-rest-spread", "transform-regenerator"]
|
||||
}
|
||||
@@ -104,6 +104,10 @@ export function _containerInsertAfter(nodes) {
|
||||
*/
|
||||
|
||||
export function insertAfter(nodes) {
|
||||
return this._insertAfter(nodes);
|
||||
}
|
||||
|
||||
export function _insertAfter(nodes, shouldRequeue = false) {
|
||||
this._assertUnremoved();
|
||||
|
||||
nodes = this._verifyNodeList(nodes);
|
||||
@@ -112,7 +116,10 @@ export function insertAfter(nodes) {
|
||||
this.parentPath.isExpressionStatement() ||
|
||||
this.parentPath.isLabeledStatement()
|
||||
) {
|
||||
return this.parentPath.insertAfter(nodes);
|
||||
// `replaceWithMultiple` requeues if there's a replacement for this.node,
|
||||
// but not for an ancestor's. Set `shouldRequeue` to true so that any replacement
|
||||
// for an ancestor node can be enqueued. Fix #5628 and #5023.
|
||||
return this.parentPath._insertAfter(nodes, true);
|
||||
} else if (
|
||||
this.isNodeType("Expression") ||
|
||||
(this.parentPath.isForStatement() && this.key === "init")
|
||||
@@ -136,6 +143,9 @@ export function insertAfter(nodes) {
|
||||
nodes.unshift(this.node);
|
||||
}
|
||||
this._replaceWith(t.blockStatement(nodes));
|
||||
if (shouldRequeue) {
|
||||
this.requeue();
|
||||
}
|
||||
} else {
|
||||
throw new Error(
|
||||
"We don't know what to do with this node type. " +
|
||||
|
||||
Reference in New Issue
Block a user