Skip to content

Commit

Permalink
Remove folding Array.prototype.concat (fix #577) (#578)
Browse files Browse the repository at this point in the history
* Remove folding Array.prototype.concat (fix #577)

* Add another test
  • Loading branch information
boopathi committed Jun 14, 2017
1 parent f8d4f07 commit 6a14696
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
Expand Up @@ -107,10 +107,8 @@ describe("constant-folding-plugin", () => {
it("should handle Array methods on array literals", () => {
const source = unpad(
`
[1, 2, 3].concat([4, 5, 6]);
[a, b, c].concat([d, e], f, g, [h]);
[1, 2, 3]["concat"]([4, 5, 6]);
[1, 2, 3].push([4, 5, 6]);
[1, 2, 3]["push"]([4, 5, 6]);
[1, 2, 3].join();
["a", "b", "c"].join();
Expand Down Expand Up @@ -142,9 +140,7 @@ describe("constant-folding-plugin", () => {
);
const expected = unpad(
`
[1, 2, 3, 4, 5, 6];
[a, b, c, d, e, f, g, h];
[1, 2, 3, 4, 5, 6];
4;
4;
"1,2,3";
Expand Down
10 changes: 0 additions & 10 deletions packages/babel-plugin-minify-constant-folding/src/replacements.js
Expand Up @@ -32,16 +32,6 @@ module.exports = ({ types: t }) => {
}
},
calls: {
concat(...args) {
return t.arrayExpression(
this.elements.concat(
...args.map(arg => {
if (t.isArrayExpression(arg)) return arg.elements;
return arg;
})
)
);
},
join(sep = t.stringLiteral(",")) {
if (!t.isStringLiteral(sep)) return;
let bad = false;
Expand Down

0 comments on commit 6a14696

Please sign in to comment.