diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-06-01 18:11:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-01 18:11:16 +0800 |
commit | bac14ba881729fa573effa1fb4afdb76a7c5662e (patch) | |
tree | 29c8603a70e4b1f888c94abfd3aede5c24a826c0 /lib | |
parent | ec095ed647691b3458ec9e65e89ff92d5151abc4 (diff) | |
download | tracifyjs-bac14ba881729fa573effa1fb4afdb76a7c5662e.tar.gz tracifyjs-bac14ba881729fa573effa1fb4afdb76a7c5662e.zip |
fix non-identifier getter/setter name (#2041)
fixes #2040
Diffstat (limited to 'lib')
-rw-r--r-- | lib/output.js | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/lib/output.js b/lib/output.js index e9765f7c..2fb7441b 100644 --- a/lib/output.js +++ b/lib/output.js @@ -1234,9 +1234,8 @@ function OutputStream(options) { }); else output.print("{}"); }); - DEFPRINT(AST_ObjectKeyVal, function(self, output){ - var key = self.key; - var quote = self.quote; + + function print_property_name(key, quote, output) { if (output.option("quote_keys")) { output.print_string(key + ""); } else if ((typeof key == "number" @@ -1253,20 +1252,24 @@ function OutputStream(options) { } else { output.print_string(key, quote); } + } + + DEFPRINT(AST_ObjectKeyVal, function(self, output){ + print_property_name(self.key, self.quote, output); output.colon(); self.value.print(output); }); - DEFPRINT(AST_ObjectSetter, function(self, output){ - output.print("set"); + AST_ObjectProperty.DEFMETHOD("_print_getter_setter", function(type, output) { + output.print(type); output.space(); - self.key.print(output); - self.value._do_print(output, true); + print_property_name(this.key.name, this.quote, output); + this.value._do_print(output, true); + }); + DEFPRINT(AST_ObjectSetter, function(self, output){ + self._print_getter_setter("set", output); }); DEFPRINT(AST_ObjectGetter, function(self, output){ - output.print("get"); - output.space(); - self.key.print(output); - self.value._do_print(output, true); + self._print_getter_setter("get", output); }); DEFPRINT(AST_Symbol, function(self, output){ var def = self.definition(); |