diff --git a/src/babel/traversal/scope/index.js b/src/babel/traversal/scope/index.js index c322f4e182..7c3eff027d 100644 --- a/src/babel/traversal/scope/index.js +++ b/src/babel/traversal/scope/index.js @@ -105,14 +105,6 @@ var renameVisitor = { } }, - Declaration(node, parent, scope, state) { - var ids = this.getBindingIdentifiers(); - - for (var name in ids) { - if (name === state.oldName) ids[name].name = state.newName; - } - }, - Scope(node, parent, scope, state) { if (!scope.bindingIdentifierEquals(state.oldName, state.binding)) { this.skip(); @@ -120,6 +112,15 @@ var renameVisitor = { } }; +renameVisitor.AssignmentExpression = +renameVisitor.Declaration = function (node, parent, scope, state) { + var ids = this.getBindingIdentifiers(); + + for (var name in ids) { + if (name === state.oldName) ids[name].name = state.newName; + } +}; + export default class Scope { /** @@ -548,15 +549,6 @@ export default class Scope { return false; } - /** - * Description - */ - - recrawl() { - this.path.setData("scopeInfo", null); - this.crawl(); - } - /** * Description */ diff --git a/src/babel/types/validators.js b/src/babel/types/validators.js index 77e1c9ef3d..b186db335f 100644 --- a/src/babel/types/validators.js +++ b/src/babel/types/validators.js @@ -99,6 +99,7 @@ export function isReferenced(node: Object, parent: Object): boolean { // no: [NODE = foo] = []; // yes: [foo = NODE] = []; + case "AssignmentExpression": case "AssignmentPattern": return parent.right === node;