allow duplicate property names in object literals for ES6+
This commit is contained in:
@@ -1865,7 +1865,7 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
if (prop instanceof AST_Node) break;
|
if (prop instanceof AST_Node) break;
|
||||||
prop = "" + prop;
|
prop = "" + prop;
|
||||||
if (compressor.has_directive("use strict")) {
|
if (compressor.option("ecma") < 6 && compressor.has_directive("use strict")) {
|
||||||
if (!all(def.value.properties, function(node) {
|
if (!all(def.value.properties, function(node) {
|
||||||
return node.key != prop && node.key.name != prop;
|
return node.key != prop && node.key.name != prop;
|
||||||
})) break;
|
})) break;
|
||||||
|
|||||||
@@ -1865,3 +1865,32 @@ issue_2816: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "3 2 4"
|
expect_stdout: "3 2 4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_2816_ecma6: {
|
||||||
|
options = {
|
||||||
|
ecma: "6",
|
||||||
|
join_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
var o = {
|
||||||
|
a: 1
|
||||||
|
};
|
||||||
|
o.b = 2;
|
||||||
|
o.a = 3;
|
||||||
|
o.c = 4;
|
||||||
|
console.log(o.a, o.b, o.c);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
var o = {
|
||||||
|
a: 1,
|
||||||
|
b: 2,
|
||||||
|
a: 3,
|
||||||
|
c: 4
|
||||||
|
};
|
||||||
|
console.log(o.a, o.b, o.c);
|
||||||
|
}
|
||||||
|
expect_stdout: "3 2 4"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user