Skip to content

Commit

Permalink
fixes misstake while es6 refactoring, add support for other variable …
Browse files Browse the repository at this point in the history
…declarations
  • Loading branch information
sokra committed Apr 12, 2017
1 parent 813053e commit ba3688a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ class Parser extends Tapable {
{
const renameIdentifier = declarator.init && this.getRenameIdentifier(declarator.init);
if(renameIdentifier && declarator.id.type === "Identifier" && this.applyPluginsBailResult1("can-rename " + renameIdentifier, declarator.init)) {
// renaming with "const a = b;"
// renaming with "var a = b;"
if(!this.applyPluginsBailResult1("rename " + renameIdentifier, declarator.init)) {
this.scope.renames["$" + declarator.id.name] = this.scope.renames["$" + renameIdentifier] || renameIdentifier;
const idx = this.scope.definitions.indexOf(declarator.id.name);
Expand All @@ -717,9 +717,11 @@ class Parser extends Tapable {
} else {
this.walkPattern(declarator.id);
this.enterPattern(declarator.id, (name, decl) => {
if(!this.applyPluginsBailResult1("const " + name, decl)) {
this.scope.renames["$" + name] = undefined;
this.scope.definitions.push(name);
if(!this.applyPluginsBailResult1("var-" + declarator.kind + " " + name, decl)) {
if(!this.applyPluginsBailResult1("var " + name, decl)) {
this.scope.renames["$" + name] = undefined;
this.scope.definitions.push(name);
}
}
});
if(declarator.init)
Expand Down

0 comments on commit ba3688a

Please sign in to comment.