Skip to content

Commit

Permalink
fix corner case in join_vars (#3917)
Browse files Browse the repository at this point in the history
fixes #3916
  • Loading branch information
alexlamsl committed May 21, 2020
1 parent aeb9ea5 commit fa14a9c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -2508,7 +2508,7 @@ merge(Compressor.prototype, {
}
if (prop instanceof AST_Node) break;
prop = "" + prop;
var diff = compressor.has_directive("use strict") ? function(node) {
var diff = prop == "__proto__" || compressor.has_directive("use strict") ? function(node) {
return node.key != prop && node.key.name != prop;
} : function(node) {
return node.key.name != prop;
Expand Down
32 changes: 32 additions & 0 deletions test/compress/join_vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -1023,3 +1023,35 @@ issue_3856: {
}
expect_stdout: "undefined"
}

issue_3916: {
options = {
join_vars: true,
}
input: {
var o = {};
o.p = "PASS";
o.__proto__ = 42;
o.q = "FAIL";
o.__proto__ = {
p: "FAIL",
q: "PASS",
};
o.__proto__ = "foo";
console.log(typeof o.__proto__, o.p, delete o.q, o.q);
}
expect: {
var o = {
p: "PASS",
__proto__: 42,
q: "FAIL",
};
o.__proto__ = {
p: "FAIL",
q: "PASS",
};
o.__proto__ = "foo";
console.log(typeof o.__proto__, o.p, delete o.q, o.q);
}
expect_stdout: "object PASS true PASS"
}

0 comments on commit fa14a9c

Please sign in to comment.