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:
parent
e1491de6b8
commit
c28415c38a
@ -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;
|
||||
}
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
var obj = {
|
||||
search: function({search}) {
|
||||
console.log(search);
|
||||
}
|
||||
};
|
||||
|
||||
function search({search}) {
|
||||
console.log(search);
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
var obj = {
|
||||
search: function search(_ref) {
|
||||
var _search = _ref.search;
|
||||
|
||||
console.log(_search);
|
||||
}
|
||||
};
|
||||
|
||||
function search(_ref2) {
|
||||
var search = _ref2.search;
|
||||
|
||||
console.log(search);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user