Skip to content

Commit

Permalink
support destructing on assignment
Browse files Browse the repository at this point in the history
fixes #4870
  • Loading branch information
sokra committed May 21, 2017
1 parent 6d24f0d commit 272c105
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/Parser.js
Expand Up @@ -993,8 +993,9 @@ class Parser extends Tapable {
}
} else {
this.walkExpression(expression.right);
this.scope.renames["$" + expression.left.name] = undefined;
this.walkExpression(expression.left);
this.enterPattern(expression.left, (name, decl) => {
this.scope.renames["$" + name] = undefined;
});
}
}

Expand Down
1 change: 1 addition & 0 deletions test/cases/parsing/issue-4870/file.js
@@ -0,0 +1 @@
export var test = "test";
13 changes: 13 additions & 0 deletions test/cases/parsing/issue-4870/index.js
@@ -0,0 +1,13 @@
import { test } from "./file";

it("should allow import in array destructing", function() {
var other;
[other = test] = [];
other.should.be.eql("test");
});

it("should allow import in object destructing", function() {
var other;
({other = test} = {});
other.should.be.eql("test");
});
6 changes: 6 additions & 0 deletions test/cases/parsing/issue-4870/test.filter.js
@@ -0,0 +1,6 @@
var supportsIteratorDestructuring = require("../../../helpers/supportsIteratorDestructuring");
var supportsObjectDestructuring = require("../../../helpers/supportsObjectDestructuring");

module.exports = function(config) {
return !config.minimize && supportsObjectDestructuring() && supportsIteratorDestructuring();
};

0 comments on commit 272c105

Please sign in to comment.