Alex Lam S.L
7f8d72d9d3
update test ( #1441 )
...
improved reduce_vars & binary operands produce more optimal results
2017-01-26 12:59:32 +01:00
Alex Lam S.L
1eaa211e09
fix mangling collision with keep_fnames ( #1431 )
...
* fix mangling collision with keep_fnames
fixes #1423
* pass mangle options to figure_out_scope()
bring command-line in line with minify()
2017-01-26 12:18:28 +01:00
Alex Lam S.L
0610c020b1
optimise binary operands with evaluate() ( #1427 )
...
- remove call to evaluate() in is_constant() and let nested optimize() does its job instead
- reject RegExp in is_constant() and remove special case logic under collapse_vars
- operands to conditionals optimisation are now always evaluate()-ed
- throw error in constant_value() instead of returning undefined to catch possible bugs, similar to make_node_from_constant()
- optimise binary boolean operators under `evaluate` instead of `conditionals`
2017-01-26 12:16:50 +01:00
Alex Lam S.L
0d7d4918eb
augment evaluate to extract within objects ( #1425 )
...
- gated by `unsafe`
- replaces previous optimisation specific to String.length
- "123"[0] => 1
- [1, 2, 3][0] => 1
- [1, 2, 3].length => 3
- does not apply to objects with overridden prototype functions
2017-01-26 12:14:18 +01:00
alexlamsl
48284844a4
add missing LHS cases which global_defs should avoid
2017-01-19 21:06:28 +01:00
kzc
ec2e5fa3a2
Have minify() and tests use figure_out_scope() as uglifyjs CLI does
...
Clarify docs, help and tests for --support-ie8 and screw_ie8=false
2017-01-19 17:14:33 +01:00
Anthony Van de Gejuchte
da17766ddd
Add preventive test involving non-ascii function identifiers
2017-01-19 17:13:33 +01:00
Ashley (Scirra)
2a9989dd18
Add --mangle-props-debug and fix --mangle-props=unquoted collision
...
Patch by @AshleyScirra
Based on: PR #1316
Renamed the CLI debug option to --mangle-props-debug
Fixes : #1321 name collision in --mangle-props=unquoted
2016-11-29 20:25:39 +01:00
Anthony Van de Gejuchte
057de570e6
Pass mangle options to figure_out_scope before mangling in tests
2016-10-27 22:55:49 +02:00
Richard van Velzen
6389e52305
Remove console.log and add extra test case
2016-10-06 14:11:32 +02:00
Richard van Velzen
e05510f3bc
Add an option to wrap IIFEs in parenthesis
...
For #1307 .
2016-10-06 14:11:32 +02:00
kzc
fc9804b909
Fix (typeof side_effect()) in boolean context
...
Fixes #1289 with suggestion by @rvanvelzen
2016-10-06 13:50:11 +02:00
alexlamsl
4761d07e0b
Optimize unmodified variables
2016-10-01 11:36:11 +02:00
kzc
25fc02743a
Account for side effects in string + expr optimization
2016-09-01 09:24:56 -04:00
kzc
0bd8053524
implement optimization: (x = 2 * x) ---> (x *= 2)
2016-08-30 08:43:02 -04:00
Richard van Velzen
8430123e9d
Fix negate_iife transform to return a correct tree for nested IIFEs
...
Fix for #1256 , partially reverts d854523783
2016-08-17 11:55:59 +02:00
kzc
d854523783
Fix negate_iife regression #1254
2016-08-17 01:29:34 -04:00
kzc
de619ae5a6
Fix --mangle-props and --mangle-props=unquoted
...
Fixes : #1247
Fix --mangle-props and --name-cache inconsistency.
AST_Dot and AST_Sub properties are now mangled by --mangle-props
without regard to being used in an assignment statement.
Note: if --mangle-props is used then *all* javascript files used must
be uglified with the same mangle options.
Fix the ignore_quoted=true mangle option, also known as
`--mangle-props=unquoted`. If a given property is quoted anywhere
it will not be mangled in any quoted or non-quoted context.
2016-08-14 21:51:25 +02:00
kzc
86859f6d7e
Additional object literal property tests
2016-08-14 21:49:43 +02:00
kzc
fb049d3a81
Fix unneeded parens around unary args in new expression.
2016-08-14 21:38:38 +02:00
Anthony Van de Gejuchte
7eb52d2837
Keep const in own scope while compressing
...
- Fixes #1205
- Fix provided by @kzc
2016-07-15 13:20:52 +02:00
kzc
eb63fece2f
Fix mangle with option keep_fnames=true for Safari.
...
Fixes : #1202
2016-07-15 13:18:14 +02:00
kzc
02c638209e
Enable --screw-ie8 by default.
...
catch identifier is mangled correctly for ES5 standards-compliant JS engines by default.
Unconditionally use the ie8 if/do-while workaround whether or not --screw-ie8 is enabled.
To support non-standard ie8 javascript use: uglifyjs --support-ie8
2016-06-30 21:49:48 +02:00
Anthony Van de Gejuchte
3a7d53f3cf
Move OctalEscapeSequence to read_escape_char
...
This should simplify and improve implementation, make it easier to
implement template strings, and keep master a bit more in sync with
harmony.
Previous implementation wasn't broken, though the loop gave me the
impression it could read infinite numbers and annoyed me a bit. It was
also slightly unnecessary because the lookup involved only 3 characters.
2016-06-30 21:42:15 +02:00
kzc
ace8aaa0f4
Fix conditional expressions of form (x ? -1 : -1)
...
Fixes #1154 , #1153
2016-06-21 14:52:13 -04:00
kzc
0c003c92a8
Don't replace undefined, NaN and Infinity within with scope
2016-06-21 10:53:29 +02:00
Shrey Banga
e645ba84cf
Respect quote style in object literals
...
The option added in fbbaa42ee5 wasn't
being respected inside object literals, so quoted property names would
still be stripped out with this option.
This is mostly a corner-case, but useful when the output is passed to
something like the Closure compiler, where quoted property names can be
used to prevent mangling.
2016-06-19 21:13:31 +02:00
Anthony Van de Gejuchte
d7971ba0e4
Fix test262 failures related to <, <=, in and instanceof
...
Fixed-by: @kzc
2016-06-15 23:11:08 +02:00
Anthony Van de Gejuchte
6c8e001fee
Stop dropping args in new expressions
2016-06-12 17:17:17 +02:00
David Bau
f99b7b630d
Escape null characters as \0 unless followed by 0-7.
2016-06-12 14:32:32 +02:00
Anthony Van de Gejuchte
ea31da2455
Don't drop unused if scope uses with statement
...
Fix provided by @kzc
2016-06-12 14:30:28 +02:00
Anthony Van de Gejuchte
8287ef6781
Fix uglify attempting to rewrite invalid new expressions
2016-06-08 19:45:21 +02:00
kzc
09d5707a8a
collapse_vars: Do not consider RegExp literals to be constants
...
Fixes #1100
2016-05-27 00:03:51 -04:00
kzc
1e390269d4
Optimize if_return for single if/return cases.
...
Fixes #1089
2016-05-24 17:54:08 +02:00
Richard van Velzen
bc49dfd27a
Completely allow evaluating -0
2016-05-24 17:50:29 +02:00
Richard van Velzen
27eedbc302
Never produce -0 when evaluating expressions (like -"")
...
Fix for #1085 . The major case was already there, but more expressions can result in -0.
2016-05-17 22:34:38 +02:00
kzc
5f464b41e2
Simplify iife new fix
...
as suggested by @rvanvelzen.
Added a test for IIFEs in nested contexts.
2016-05-15 19:12:17 -04:00
kzc
bcc1318d4b
Do not apply negate_iife optimization to new expression
2016-05-09 03:19:28 -04:00
Richard van Velzen
e9224ab444
Add test cases for slightly more esoteric cases
2016-04-26 11:49:55 +02:00
Richard van Velzen
4d9a085687
Add test case for hoisting a single function
2016-04-26 11:43:03 +02:00
Richard van Velzen
4fe630431c
Hoist functions when reversing if (x) return; ... vs. if (!x) ...
...
Fixes #1052
2016-04-23 23:48:33 +02:00
kzc
c55dd5ed74
Add passes compress option. Fix duplicate compress warnings.
2016-04-19 20:05:33 +02:00
Richard van Velzen
4b4528ee05
Prevent endless recursion when evaluating self-referencing consts
...
Fix #1041
2016-04-13 15:03:31 +02:00
Richard van Velzen
187a0caf9d
Add base54.reset() to compress tests
...
Without this reset, char counts bleed to next tests. One test had a bad expect clause.
2016-04-12 20:08:09 +02:00
kzc
3907a5e3b2
Fix warnings for referenced non-hoisted functions.
...
Fixes #1034
Also added `expect_warnings` functionality to test framework.
2016-04-11 18:15:20 +02:00
kzc
98434258d0
Optimize ternaries with boolean consequent or alternative.
...
Fixes #511
2016-04-02 17:22:12 +02:00
kzc
07bb7262d0
Escape all ASCII control characters within strings when using ascii_only.
...
Fixes #1017 .
Tab characters within strings are now output as `\t` in all output modes.
2016-03-24 11:51:54 -04:00
philippsimon
ee6c9fabb7
Fix: Uglified Number.prototype functions on big numbers
2016-03-14 12:41:06 +01:00
kzc
11b0efdf84
boolean_expression ? true : false --> boolean_expression
2016-02-22 17:59:36 +01:00
kzc
5486b68850
Take operator || precendence into account for AST_If optimization.
...
Fixes #979 .
2016-02-21 12:05:02 -05:00