don't consider the LHS of an AssignmentExpression to be a reference

This commit is contained in:
Sebastian McKenzie 2015-06-04 22:07:44 +01:00
parent 45b0d63d72
commit 355ffbdaf8
2 changed files with 10 additions and 17 deletions

View File

@ -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
*/

View File

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