@@ -8638,17 +8638,26 @@ Compressor.prototype.compress = function(node) {
|
|||||||
if (base || self.name || !compressor.has_directive("use strict")) {
|
if (base || self.name || !compressor.has_directive("use strict")) {
|
||||||
var node = to_class_expr(self);
|
var node = to_class_expr(self);
|
||||||
if (!base) node.extends = null;
|
if (!base) node.extends = null;
|
||||||
node.properties = values ? values.length == init ? values : [ make_node(AST_ClassField, self, {
|
node.properties = [];
|
||||||
|
if (values) {
|
||||||
|
if (values.length == init) {
|
||||||
|
if (exprs.length) values.unshift(make_node(AST_ClassField, self, {
|
||||||
|
key: make_sequence(self, exprs),
|
||||||
|
value: null,
|
||||||
|
}));
|
||||||
|
node.properties = values;
|
||||||
|
} else node.properties.push(make_node(AST_ClassField, self, {
|
||||||
static: true,
|
static: true,
|
||||||
key: exprs.length ? make_sequence(self, exprs) : "c",
|
key: exprs.length ? make_sequence(self, exprs) : "c",
|
||||||
value: make_value(),
|
value: make_value(),
|
||||||
}) ] : exprs.length ? [ make_node(AST_ClassMethod, self, {
|
}));
|
||||||
|
} else if (exprs.length) node.properties.push(make_node(AST_ClassMethod, self, {
|
||||||
key: make_sequence(self, exprs),
|
key: make_sequence(self, exprs),
|
||||||
value: make_node(AST_Function, self, {
|
value: make_node(AST_Function, self, {
|
||||||
argnames: [],
|
argnames: [],
|
||||||
body: [],
|
body: [],
|
||||||
}).init_vars(node),
|
}).init_vars(node),
|
||||||
}) ] : [];
|
}));
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
if (values) exprs.push(make_node(AST_Call, self, {
|
if (values) exprs.push(make_node(AST_Call, self, {
|
||||||
|
|||||||
@@ -3084,3 +3084,62 @@ issue_5481: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5489: {
|
||||||
|
options = {
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(class {
|
||||||
|
[console.log("foo")];
|
||||||
|
static {
|
||||||
|
console.log("bar");
|
||||||
|
}
|
||||||
|
static [console.log("baz")]() {}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(class {
|
||||||
|
[(console.log("foo"), console.log("baz"))];
|
||||||
|
static {
|
||||||
|
console.log("bar");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"baz",
|
||||||
|
"bar",
|
||||||
|
]
|
||||||
|
node_version: ">=16"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5489_strict: {
|
||||||
|
options = {
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
(class {
|
||||||
|
[console.log("foo")];
|
||||||
|
static {
|
||||||
|
console.log("bar");
|
||||||
|
}
|
||||||
|
static [console.log("baz")]() {}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
console.log("foo"),
|
||||||
|
console.log("baz"),
|
||||||
|
(() => (() => {
|
||||||
|
console.log("bar");
|
||||||
|
})())();
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"baz",
|
||||||
|
"bar",
|
||||||
|
]
|
||||||
|
node_version: ">=16"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user