From c2112d588695791d71d6d362232be6c2b5641f90 Mon Sep 17 00:00:00 2001 From: Anthony Van de Gejuchte Date: Mon, 24 Oct 2016 23:35:14 +0200 Subject: [PATCH] Fix case where a lonely var is used as computed property --- lib/output.js | 2 +- test/compress/object.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/output.js b/lib/output.js index eb42d0fa..83b3253b 100644 --- a/lib/output.js +++ b/lib/output.js @@ -1508,7 +1508,7 @@ function OutputStream(options) { ) { self.print_property_name(self.key, self.quote, output); } else { - if (!(self.key instanceof AST_Node) || self.key instanceof AST_Symbol) { + if (!(self.key instanceof AST_Node)) { self.print_property_name(self.key, self.quote, output); } else { output.with_square(function() { diff --git a/test/compress/object.js b/test/compress/object.js index c3ad2989..724e0877 100644 --- a/test/compress/object.js +++ b/test/compress/object.js @@ -491,3 +491,14 @@ allow_assignments_to_property_values: { var foo = {123: foo = 123} = {foo: "456"}; } } + +variable_as_computed_property: { + input: { + function getLine(header) { + return { + [header]: {} + }; + } + } + expect_exact: "function getLine(header){return{[header]:{}}}" +} \ No newline at end of file