From 355ffbdaf823060fa111d50fb15bad20777b763c Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Thu, 4 Jun 2015 22:07:44 +0100 Subject: [PATCH] don't consider the LHS of an AssignmentExpression to be a reference --- src/babel/traversal/scope/index.js | 26 +++++++++----------------- src/babel/types/validators.js | 1 + 2 files changed, 10 insertions(+), 17 deletions(-) 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;