@@ -4828,7 +4828,7 @@ merge(Compressor.prototype, {
|
||||
}
|
||||
if (is_lhs(self, compressor.parent())) return self;
|
||||
if (compressor.option("properties") && key !== prop) {
|
||||
var node = self.flatten_object(property);
|
||||
var node = self.flatten_object(property, compressor);
|
||||
if (node) {
|
||||
expr = self.expression = node.expression;
|
||||
prop = self.property = node.property;
|
||||
@@ -4888,22 +4888,26 @@ merge(Compressor.prototype, {
|
||||
return result;
|
||||
});
|
||||
|
||||
AST_PropAccess.DEFMETHOD("flatten_object", function(key) {
|
||||
AST_PropAccess.DEFMETHOD("flatten_object", function(key, compressor) {
|
||||
var arrows = compressor.option("unsafe_arrows") && compressor.option("ecma") >= 6;
|
||||
var expr = this.expression;
|
||||
if (expr instanceof AST_Object) {
|
||||
var props = expr.properties;
|
||||
for (var i = props.length; --i >= 0;) {
|
||||
var prop = props[i];
|
||||
if ("" + prop.key == key) {
|
||||
if ("" + (prop instanceof AST_ConciseMethod ? prop.key.name : prop.key) == key) {
|
||||
if (!all(props, function(prop) {
|
||||
return prop instanceof AST_ObjectKeyVal;
|
||||
return prop instanceof AST_ObjectKeyVal
|
||||
|| arrows && prop instanceof AST_ConciseMethod && !prop.is_generator;
|
||||
})) break;
|
||||
var value = prop.value;
|
||||
if (value instanceof AST_Function && value.contains_this()) break;
|
||||
if ((value instanceof AST_Accessor || value instanceof AST_Function)
|
||||
&& value.contains_this()) break;
|
||||
return make_node(AST_Sub, this, {
|
||||
expression: make_node(AST_Array, expr, {
|
||||
elements: props.map(function(prop) {
|
||||
return prop.value;
|
||||
var v = prop.value;
|
||||
return v instanceof AST_Accessor ? make_node(AST_Function, v, v) : v;
|
||||
})
|
||||
}),
|
||||
property: make_node(AST_Number, this, {
|
||||
@@ -4944,7 +4948,7 @@ merge(Compressor.prototype, {
|
||||
}
|
||||
if (is_lhs(self, compressor.parent())) return self;
|
||||
if (compressor.option("properties")) {
|
||||
var node = self.flatten_object(self.property);
|
||||
var node = self.flatten_object(self.property, compressor);
|
||||
if (node) return node.optimize(compressor);
|
||||
}
|
||||
var ev = self.evaluate(compressor);
|
||||
|
||||
Reference in New Issue
Block a user