@@ -1690,28 +1690,21 @@ function OutputStream(options) {
|
|||||||
|
|
||||||
function print_property_key(self, output) {
|
function print_property_key(self, output) {
|
||||||
var key = self.key;
|
var key = self.key;
|
||||||
if (key instanceof AST_Node) {
|
if (key instanceof AST_Node) return output.with_square(function() {
|
||||||
output.with_square(function() {
|
key.print(output);
|
||||||
key.print(output);
|
});
|
||||||
});
|
var quote = self.start && self.start.quote;
|
||||||
} else if (output.option("quote_keys")) {
|
if (output.option("quote_keys") || quote && output.option("keep_quoted_props")) {
|
||||||
output.print_string(key);
|
output.print_string(key, quote);
|
||||||
} else if ("" + +key == key && key >= 0) {
|
} else if ("" + +key == key && key >= 0) {
|
||||||
output.print(make_num(key));
|
output.print(make_num(key));
|
||||||
|
} else if (self.private) {
|
||||||
|
output.print_name(key);
|
||||||
|
} else if (RESERVED_WORDS[key] ? !output.option("ie") : is_identifier_string(key)) {
|
||||||
|
output.print_name(key);
|
||||||
|
return key;
|
||||||
} else {
|
} else {
|
||||||
var quote = self.start && self.start.quote;
|
output.print_string(key, quote);
|
||||||
if (self.private) {
|
|
||||||
output.print_name(key);
|
|
||||||
} else if (RESERVED_WORDS[key] ? !output.option("ie") : is_identifier_string(key)) {
|
|
||||||
if (quote && output.option("keep_quoted_props")) {
|
|
||||||
output.print_string(key, quote);
|
|
||||||
} else {
|
|
||||||
output.print_name(key);
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
output.print_string(key, quote);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DEFPRINT(AST_ObjectKeyVal, function(output) {
|
DEFPRINT(AST_ObjectKeyVal, function(output) {
|
||||||
|
|||||||
@@ -1463,3 +1463,50 @@ issue_4888: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "object"
|
expect_stdout: "object"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5093: {
|
||||||
|
beautify = {
|
||||||
|
keep_quoted_props: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log({
|
||||||
|
a: true,
|
||||||
|
'42': "PASS",
|
||||||
|
"null": [],
|
||||||
|
}[6 * 7]);
|
||||||
|
}
|
||||||
|
expect_exact: 'console.log({a:true,"42":"PASS","null":[]}[6*7]);'
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5093_quote_keys: {
|
||||||
|
beautify = {
|
||||||
|
keep_quoted_props: true,
|
||||||
|
quote_keys: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log({
|
||||||
|
a: true,
|
||||||
|
'42': "PASS",
|
||||||
|
"null": [],
|
||||||
|
}[6 * 7]);
|
||||||
|
}
|
||||||
|
expect_exact: 'console.log({"a":true,"42":"PASS","null":[]}[6*7]);'
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5093_quote_style: {
|
||||||
|
beautify = {
|
||||||
|
keep_quoted_props: true,
|
||||||
|
quote_style: 3,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log({
|
||||||
|
a: true,
|
||||||
|
'42': "PASS",
|
||||||
|
"null": [],
|
||||||
|
}[6 * 7]);
|
||||||
|
}
|
||||||
|
expect_exact: 'console.log({a:true,\'42\':"PASS","null":[]}[6*7]);'
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user