diff --git a/lib/ast.js b/lib/ast.js index 68ef352a..2b835e88 100644 --- a/lib/ast.js +++ b/lib/ast.js @@ -401,9 +401,7 @@ var AST_ArrowParametersOrSeq = DEFNODE("ArrowParametersOrSeq", "expressions", { default: default_seen_above, names: ex.properties.map(to_fun_args) }); - } else if (ex instanceof AST_ObjectKeyVal || - ex instanceof AST_ObjectComputedKeyVal - ) { + } else if (ex instanceof AST_ObjectKeyVal) { if (ex.key instanceof AST_SymbolRef) { ex.key = to_fun_args(ex.key, 0, [ex.key], ex.default); } @@ -1014,10 +1012,6 @@ var AST_ObjectKeyVal = DEFNODE("ObjectKeyVal", "quote default", { } }, AST_ObjectProperty); -var AST_ObjectComputedKeyVal = DEFNODE("ObjectComputedKeyVal", null, { - $documentation: "An object property whose key is computed. Like `[Symbol.iterator]: function...` or `[routes.homepage]: renderHomepage`", -}, AST_ObjectProperty); - var AST_ObjectSetter = DEFNODE("ObjectSetter", "quote static", { $propdoc: { quote: "[string|undefined] the original quote character, if any", diff --git a/lib/compress.js b/lib/compress.js index b5b6c263..69cfbe0b 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1280,7 +1280,7 @@ merge(Compressor.prototype, { return false; }); def(AST_ObjectProperty, function(compressor){ - if (this instanceof AST_ObjectComputedKeyVal && + if (this.key instanceof AST_ObjectKeyVal && this.key.has_side_effects(compressor)) return true; return this.value.has_side_effects(compressor); diff --git a/lib/output.js b/lib/output.js index 5fac50b8..eb42d0fa 100644 --- a/lib/output.js +++ b/lib/output.js @@ -1508,7 +1508,13 @@ function OutputStream(options) { ) { self.print_property_name(self.key, self.quote, output); } else { - self.print_property_name(self.key, self.quote, output); + if (!(self.key instanceof AST_Node) || self.key instanceof AST_Symbol) { + self.print_property_name(self.key, self.quote, output); + } else { + output.with_square(function() { + self.key.print(output); + }); + } output.colon(); self.value.print(output); } @@ -1559,19 +1565,6 @@ function OutputStream(options) { } self.value._do_print(output, true); }); - DEFPRINT(AST_ObjectComputedKeyVal, function(self, output) { - output.print("["); - self.key.print(output); - output.print("]:"); - output.space(); - self.value.print(output); - if (self.default) { - output.space(); - output.print('='); - output.space(); - self.default.print(output); - } - }); AST_Symbol.DEFMETHOD("_do_print", function(output){ var def = this.definition(); output.print_name(def ? def.mangled_name || def.name : this.name); diff --git a/lib/parse.js b/lib/parse.js index aa1bda45..8c710d04 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -1507,14 +1507,6 @@ function parse($TEXT, options) { name: property_token, end: prev() })); - } else if (property instanceof AST_Node) { - expect(":"); - elements.push(new AST_ObjectComputedKeyVal({ - start: property_token, - key: property, - value: binding_element(used_parameters, symbol_type), - end: prev() - })); } else { expect(":"); elements.push(new AST_ObjectKeyVal({ @@ -1989,7 +1981,7 @@ function parse($TEXT, options) { if (type == "punc" && start.value == "[") { expect(":"); - a.push(new AST_ObjectComputedKeyVal({ + a.push(new AST_ObjectKeyVal({ start: start, key: name, value: expression(false),