Various property fixes

* Implement getter/setter with computed value
* Fix parsing getter/setter after static or generator token
* Allow storing expressions for computed expression in AST_SymbolMethod
* Allow get and set in shorthand properties in object literals

Fixes #1094, #1146 and #1221
This commit is contained in:
Anthony Van de Gejuchte
2016-07-06 00:40:28 +02:00
committed by Richard van Velzen
parent 766fafda8b
commit 72a9d799b6
6 changed files with 462 additions and 207 deletions

View File

@@ -887,8 +887,12 @@ function OutputStream(options) {
output.space();
}
}
if (self.name) {
if (self.name instanceof AST_Symbol) {
self.name.print(output);
} else if (nokeyword && self.name instanceof AST_Node) {
output.with_square(function() {
self.name.print(output); // Computed method name
});
}
output.with_parens(function(){
self.argnames.forEach(function(arg, i){
@@ -1489,6 +1493,15 @@ function OutputStream(options) {
self.default.print(output)
}
});
DEFPRINT(AST_SymbolMethod, function(self, output) {
if (self.name instanceof AST_Node) {
output.with_square(function() {
self.name.print(output);
});
} else {
self._do_print(output);
}
});
DEFPRINT(AST_Undefined, function(self, output){
output.print("void 0");
});