Fix quoting of properties
- Make AST_ConciseMethod child of AST_ObjectProperty. - Fix some typos.
This commit is contained in:
committed by
Richard van Velzen
parent
67461666dc
commit
1c15d0db45
@@ -966,16 +966,6 @@ function OutputStream(options) {
|
||||
}
|
||||
if (needs_parens) { output.print(")") }
|
||||
});
|
||||
DEFPRINT(AST_ConciseMethod, function(self, output){
|
||||
if (self.static) {
|
||||
output.print("static");
|
||||
output.space();
|
||||
}
|
||||
if (self.is_generator) {
|
||||
output.print("*");
|
||||
}
|
||||
self._do_print(output, true /* do not print "function" */);
|
||||
});
|
||||
|
||||
/* -----[ exits ]----- */
|
||||
AST_Exit.DEFMETHOD("_do_print", function(output, kind){
|
||||
@@ -1430,17 +1420,7 @@ function OutputStream(options) {
|
||||
DEFPRINT(AST_NewTarget, function(self, output) {
|
||||
output.print("new.target");
|
||||
});
|
||||
DEFPRINT(AST_ObjectKeyVal, function(self, output){
|
||||
var key = self.key;
|
||||
var quote = self.quote;
|
||||
var print_as_shorthand = self.shorthand &&
|
||||
self.value instanceof AST_Symbol &&
|
||||
self.key == self.value.print_to_string();
|
||||
|
||||
if (print_as_shorthand) {
|
||||
output.print_name(key);
|
||||
return;
|
||||
}
|
||||
AST_ObjectProperty.DEFMETHOD("print_property_name", function(key, quote, output) {
|
||||
if (output.option("quote_keys")) {
|
||||
output.print_string(key + "");
|
||||
} else if ((typeof key == "number"
|
||||
@@ -1457,6 +1437,17 @@ function OutputStream(options) {
|
||||
} else {
|
||||
output.print_string(key, quote);
|
||||
}
|
||||
});
|
||||
DEFPRINT(AST_ObjectKeyVal, function(self, output){
|
||||
var print_as_shorthand = self.shorthand &&
|
||||
self.value instanceof AST_Symbol &&
|
||||
self.key == self.value.print_to_string();
|
||||
|
||||
if (print_as_shorthand) {
|
||||
output.print_name(self.key);
|
||||
return;
|
||||
}
|
||||
self.print_property_name(self.key, self.quote, output);
|
||||
output.colon();
|
||||
self.value.print(output);
|
||||
});
|
||||
@@ -1468,11 +1459,7 @@ function OutputStream(options) {
|
||||
output.print(type);
|
||||
output.space();
|
||||
if (self.key instanceof AST_SymbolMethod) {
|
||||
if (typeof self.key.name === "string" && !is_identifier_string(self.key.name)) {
|
||||
output.print_string(self.key.name);
|
||||
} else {
|
||||
self.key.print(output);
|
||||
}
|
||||
self.print_property_name(self.key.name, self.quote, output);
|
||||
} else {
|
||||
output.with_square(function() {
|
||||
self.key.print(output);
|
||||
@@ -1486,6 +1473,24 @@ function OutputStream(options) {
|
||||
DEFPRINT(AST_ObjectGetter, function(self, output){
|
||||
self._print_getter_setter("get", self, output);
|
||||
});
|
||||
DEFPRINT(AST_ConciseMethod, function(self, output){
|
||||
if (self.static) {
|
||||
output.print("static");
|
||||
output.space();
|
||||
}
|
||||
if (self.is_generator) {
|
||||
output.print("*");
|
||||
}
|
||||
output.space();
|
||||
if (self.key instanceof AST_SymbolMethod) {
|
||||
self.print_property_name(self.key.name, self.quote, output);
|
||||
} else {
|
||||
output.with_square(function() {
|
||||
self.key.print(output);
|
||||
});
|
||||
}
|
||||
self.value._do_print(output, true);
|
||||
});
|
||||
DEFPRINT(AST_ObjectComputedKeyVal, function(self, output) {
|
||||
output.print("[");
|
||||
self.key.print(output);
|
||||
|
||||
Reference in New Issue
Block a user