support destructured shorthand for default parameters (#5059)
closes #4990
This commit is contained in:
parent
0c48b84540
commit
2340feff87
|
|
@ -1629,7 +1629,19 @@ function OutputStream(options) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var key = print_property_key(self, output);
|
var key = print_property_key(self, output);
|
||||||
var value = self.value;
|
var value = self.value;
|
||||||
if (key && value instanceof AST_SymbolDeclaration && key == get_symbol_name(value)) return;
|
if (key) {
|
||||||
|
if (value instanceof AST_DefaultValue) {
|
||||||
|
if (value.name instanceof AST_Symbol && key == get_symbol_name(value.name)) {
|
||||||
|
output.space();
|
||||||
|
output.print("=");
|
||||||
|
output.space();
|
||||||
|
value.value.print(output);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (value instanceof AST_Symbol) {
|
||||||
|
if (key == get_symbol_name(value)) return;
|
||||||
|
}
|
||||||
|
}
|
||||||
output.colon();
|
output.colon();
|
||||||
value.print(output);
|
value.print(output);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ object_shorthand_assign: {
|
||||||
({ a = "PASS" } = 42);
|
({ a = "PASS" } = 42);
|
||||||
console.log(a);
|
console.log(a);
|
||||||
}
|
}
|
||||||
expect_exact: '({a:a="PASS"}=42);console.log(a);'
|
expect_exact: '({a="PASS"}=42);console.log(a);'
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
@ -80,7 +80,7 @@ object_shorthand_declaration: {
|
||||||
var { a = "PASS" } = 42;
|
var { a = "PASS" } = 42;
|
||||||
console.log(a);
|
console.log(a);
|
||||||
}
|
}
|
||||||
expect_exact: 'var{a:a="PASS"}=42;console.log(a);'
|
expect_exact: 'var{a="PASS"}=42;console.log(a);'
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
@ -91,7 +91,7 @@ object_shorthand_function: {
|
||||||
console.log(a);
|
console.log(a);
|
||||||
})(42);
|
})(42);
|
||||||
}
|
}
|
||||||
expect_exact: '(function({a:a="PASS"}){console.log(a)})(42);'
|
expect_exact: '(function({a="PASS"}){console.log(a)})(42);'
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user