handle shorthand objects properly when renaming bindings, create new ones and refresh the stored binding identifier if necessary - fixes #1406

This commit is contained in:
Sebastian McKenzie
2015-05-01 15:23:46 +01:00
parent e1491de6b8
commit c28415c38a
3 changed files with 32 additions and 1 deletions

View File

@@ -74,8 +74,15 @@ var renameVisitor = explode({
Identifier(node, parent, scope, state) {
if (this.isReferenced() && node.name === state.oldName) {
if (this.parentPath.isProperty() && this.key === "key" && parent.shorthand) {
var value = t.identifier(state.newName);;
if (parent.value === state.binding) {
state.info.identifier = state.binding = value;
}
parent.shorthand = false;
parent.value = t.identifier(state.newName);
parent.value = value;
parent.key = t.identifier(state.oldName);
} else {
node.name = state.newName;
}