scope.rename() missing identifier in VariableDeclarator (#11595)
This commit is contained in:
parent
0ca5f8b2ec
commit
429840dc2b
@ -20,7 +20,8 @@ const renameVisitor = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
"AssignmentExpression|Declaration"(path, state) {
|
"AssignmentExpression|Declaration|VariableDeclarator"(path, state) {
|
||||||
|
if (path.isVariableDeclaration()) return;
|
||||||
const ids = path.getOuterBindingIdentifiers();
|
const ids = path.getOuterBindingIdentifiers();
|
||||||
|
|
||||||
for (const name in ids) {
|
for (const name in ids) {
|
||||||
|
|||||||
7
packages/babel-traverse/test/fixtures/rename/function-body-declaration/input.js
vendored
Normal file
7
packages/babel-traverse/test/fixtures/rename/function-body-declaration/input.js
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
function c(b) {
|
||||||
|
var a = b + 1,
|
||||||
|
a = a + 1,
|
||||||
|
a = a + 1;
|
||||||
|
|
||||||
|
return a;
|
||||||
|
}
|
||||||
3
packages/babel-traverse/test/fixtures/rename/function-body-declaration/options.json
vendored
Normal file
3
packages/babel-traverse/test/fixtures/rename/function-body-declaration/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["./plugin"]
|
||||||
|
}
|
||||||
7
packages/babel-traverse/test/fixtures/rename/function-body-declaration/output.js
vendored
Normal file
7
packages/babel-traverse/test/fixtures/rename/function-body-declaration/output.js
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
function c(b) {
|
||||||
|
var _a = b + 1,
|
||||||
|
_a = _a + 1,
|
||||||
|
_a = _a + 1;
|
||||||
|
|
||||||
|
return _a;
|
||||||
|
}
|
||||||
9
packages/babel-traverse/test/fixtures/rename/function-body-declaration/plugin.js
vendored
Normal file
9
packages/babel-traverse/test/fixtures/rename/function-body-declaration/plugin.js
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
module.exports = function() {
|
||||||
|
return {
|
||||||
|
visitor: {
|
||||||
|
Scope(path) {
|
||||||
|
path.scope.rename("a", "_a");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user