17
README.md
17
README.md
@@ -930,6 +930,9 @@ can pass additional arguments that control the code output:
|
||||
}
|
||||
```
|
||||
|
||||
- `extendscript` (default: `false`) — enable workarounds for Adobe ExtendScript
|
||||
bugs
|
||||
|
||||
- `galio` (default: `false`) — enable workarounds for ANT Galio bugs
|
||||
|
||||
- `indent_level` (default: `4`) — indent by specified number of spaces or the
|
||||
@@ -1446,3 +1449,17 @@ To allow for better optimizations, the compiler makes various assumptions:
|
||||
// Actual: TypeError: invalid assignment to const 'f'
|
||||
```
|
||||
UglifyJS may modify the input which in turn may suppress those errors.
|
||||
- Adobe ExtendScript will give incorrect results with the following:
|
||||
```javascript
|
||||
alert(true ? "PASS" : false ? "FAIL" : null);
|
||||
// Expected: "PASS"
|
||||
// Actual: "FAIL"
|
||||
```
|
||||
UglifyJS may modify the input which in turn may suppress those errors.
|
||||
- Adobe ExtendScript will give incorrect results with the following:
|
||||
```javascript
|
||||
alert(42 ? null ? "FAIL" : "PASS" : "FAIL");
|
||||
// Expected: "PASS"
|
||||
// Actual: SyntaxError: Expected: :
|
||||
```
|
||||
UglifyJS may modify the input which in turn may suppress those errors.
|
||||
|
||||
@@ -55,6 +55,7 @@ function OutputStream(options) {
|
||||
beautify : false,
|
||||
braces : false,
|
||||
comments : false,
|
||||
extendscript : false,
|
||||
galio : false,
|
||||
ie : false,
|
||||
indent_level : 4,
|
||||
@@ -700,6 +701,7 @@ function OutputStream(options) {
|
||||
if (p instanceof AST_Class) return true;
|
||||
// (x++)[y]
|
||||
// (typeof x).y
|
||||
// https://github.com/mishoo/UglifyJS/issues/115
|
||||
if (p instanceof AST_PropAccess) return p.expression === this;
|
||||
// (~x)`foo`
|
||||
if (p instanceof AST_Template) return p.tag === this;
|
||||
@@ -875,7 +877,9 @@ function OutputStream(options) {
|
||||
return needs_parens_assign_cond(this, output);
|
||||
});
|
||||
PARENS(AST_Conditional, function(output) {
|
||||
return needs_parens_assign_cond(this, output);
|
||||
return needs_parens_assign_cond(this, output)
|
||||
// https://github.com/mishoo/UglifyJS/issues/1144
|
||||
|| output.option("extendscript") && output.parent() instanceof AST_Conditional;
|
||||
});
|
||||
PARENS(AST_Yield, function(output) {
|
||||
return needs_parens_assign_cond(this, output);
|
||||
|
||||
@@ -1176,6 +1176,52 @@ trivial_boolean_ternary_expressions : {
|
||||
}
|
||||
}
|
||||
|
||||
extendscript_1: {
|
||||
beautify = {
|
||||
extendscript: true,
|
||||
}
|
||||
input: {
|
||||
var alert = console.log;
|
||||
function f(a, b) {
|
||||
return a ? b ? "foo" : "bar" : "baz";
|
||||
}
|
||||
alert(f());
|
||||
alert(f(42));
|
||||
alert(f(null, true));
|
||||
alert(f([], {}));
|
||||
}
|
||||
expect_exact: 'var alert=console.log;function f(a,b){return a?(b?"foo":"bar"):"baz"}alert(f());alert(f(42));alert(f(null,true));alert(f([],{}));'
|
||||
expect_stdout: [
|
||||
"baz",
|
||||
"bar",
|
||||
"baz",
|
||||
"foo",
|
||||
]
|
||||
}
|
||||
|
||||
extendscript_2: {
|
||||
beautify = {
|
||||
extendscript: true,
|
||||
}
|
||||
input: {
|
||||
var alert = console.log;
|
||||
function f(a, b) {
|
||||
return a ? "foo" : b ? "bar" : "baz";
|
||||
}
|
||||
alert(f());
|
||||
alert(f(42));
|
||||
alert(f(null, true));
|
||||
alert(f([], {}));
|
||||
}
|
||||
expect_exact: 'var alert=console.log;function f(a,b){return a?"foo":(b?"bar":"baz")}alert(f());alert(f(42));alert(f(null,true));alert(f([],{}));'
|
||||
expect_stdout: [
|
||||
"baz",
|
||||
"foo",
|
||||
"bar",
|
||||
"foo",
|
||||
]
|
||||
}
|
||||
|
||||
issue_1154: {
|
||||
options = {
|
||||
booleans: true,
|
||||
|
||||
Reference in New Issue
Block a user