Skip to content

Commit

Permalink
enhance properties (#3721)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlamsl committed Feb 15, 2020
1 parent 0d820e4 commit f0a2990
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/compress.js
Expand Up @@ -7615,9 +7615,11 @@ merge(Compressor.prototype, {
value = value.fixed_value();
}
if (!value) return false;
return !(value instanceof AST_Lambda)
|| compressor.parent() instanceof AST_New
|| !value.contains_this();
if (!(value instanceof AST_Lambda)) return true;
var parent = compressor.parent();
if (parent.TYPE != "Call") return true;
if (parent.expression !== compressor.self()) return true;
return !value.contains_this();
}

OPT(AST_Sub, function(self, compressor) {
Expand Down
23 changes: 23 additions & 0 deletions test/compress/properties.js
Expand Up @@ -817,6 +817,29 @@ issue_2208_5: {
expect_stdout: "42"
}

issue_2208_6: {
options = {
inline: true,
properties: true,
side_effects: true,
}
input: {
a = 42;
console.log(("FAIL", {
p: function() {
return this.a;
}
}.p)());
}
expect: {
a = 42;
console.log(function() {
return this.a;
}());
}
expect_stdout: "42"
}

issue_2256: {
options = {
side_effects: true,
Expand Down

0 comments on commit f0a2990

Please sign in to comment.