Mihai Bazon
d2d716483a
aborts(AST_If) returns the if node
...
Previously it returned the abort node from the alternative branch. This is
not much use as it can be different from the one in the body
branch (i.e. return vs. throw) and can trick us into issues like #591 .
Fix #591
2015-01-06 14:01:35 +02:00
Mihai Bazon
e1f0747e4c
Support keep_fnames in compressor, and --keep-fnames. #552
...
Passing `--keep-fnames` will enable it both for compressor/mangler, so that
function names will not be dropped (when unused) nor mangled.
2015-01-05 11:03:13 +02:00
Richard van Velzen
f4d36a58c2
Fix #569
...
When no arguments are given to `new Function()`, it should be treated as
a regular anonymous function (http://es5.github.io/#x15.3.2.1 )
2015-01-04 13:37:59 +01:00
Richard van Velzen
c75f5a1fd8
Fix #597
...
NaN and Infinity were replaced in the output generation, instead of
during compression. This could lead to results where `1/0` was inserted
without parens leading to invalid output.
The nodes are replaced in the compression step now, and the output
generation returns their regular names. This should not be a problem,
since they're already only constructed from the original name.
2014-12-31 12:23:00 +01:00
Mihai Bazon
01d19b4b52
Referencing a global is assumed to have side effects.
...
Close #550
2014-09-28 11:18:25 +03:00
Tal Ater
fb0ec720a4
Compress conditions that have side effects using sequences
2014-09-04 02:57:49 +03:00
Tal Ater
885835a655
Compress conditional assignments where all possible outcomes are equivalant and condition has no side effects
2014-09-02 23:30:25 +03:00
Mihai Bazon
4c64554808
Turn foo.new into foo["new"] when not --screw-ie8. Fix #534
2014-08-26 10:11:01 +03:00
Mihai Bazon
548beeb6b1
Prevent error for Function(""). Close #538
2014-08-20 09:16:34 +03:00
Dan Wolff
8511e80f48
Evaluate "foo".length ==> 3
2014-07-01 11:06:51 +03:00
Artemy Tregubenko
524a8a42a4
added @ngInject support for inline functions
2014-05-11 14:01:08 +02:00
Mihai Bazon
ef2ef07cbd
Add option keep_fargs.
...
By default it's `false`. Pass `true` if you need to keep unused function
arguments.
Close #188 .
2014-02-08 12:33:56 +02:00
Matt Basta
ac0086a745
Simplify nested conditionals if possible
2014-02-06 12:39:13 -08:00
Mihai Bazon
5344b7dab8
Fix if_return dropping the alternative. Close #413
2014-01-31 10:44:13 +02:00
Mihai Bazon
c3087dd179
Better process_for_angular before other statement reductions. #395
2014-01-08 11:39:24 +02:00
Mihai Bazon
2c305af478
Support @ngInject with angular compressor option. Close #395 .
2014-01-08 11:28:32 +02:00
Mihai Bazon
2c88eb6fbe
doh.
2014-01-07 12:54:14 +02:00
Mihai Bazon
27142df4f5
minor: exp["10"] => exp[10]
2014-01-07 12:48:21 +02:00
Mihai Bazon
b521b4b926
Conditional/call optimization
...
foo ? bar(x) : bar(y) ==> bar(foo ? x : y)
2013-12-29 10:31:30 +02:00
Mihai Bazon
5a083a938d
Optimize seq,void 0. Close #377 .
...
(x, void 0) => void x
(x, undefined) => void x
2013-12-22 11:36:45 +02:00
Mihai Bazon
dc5f70eab5
Add drop_console option to the compressor
2013-12-10 19:44:41 +02:00
Mihai Bazon
df8c5623af
minor
2013-12-10 19:39:03 +02:00
Mihai Bazon
d2190c2bf3
Properly scope catch identifier when --screw-ie8
...
Fix #344
2013-11-28 16:43:30 +02:00
Mihai Bazon
50b8d7272c
Fix faulty compression
...
`String(x + 5)` is not always the same as `x + "5"`. Overlooked that. :-(
Close #350
2013-11-20 21:13:16 +02:00
Mihai Bazon
7d11b96f48
Only descend twice after drop_unused if it's the same node type.
...
Fix #345
2013-11-08 11:57:17 +02:00
Mihai Bazon
eab99a1c3d
Better fix for #343
...
We can in fact lift sequences, but only if the operation is assignment and
the left-hand side has no side effects nor property access -- that should
guarantee that whatever we place before it cannot affect the sense of the
assignment.
Dropped contrived test case (too hard to support it now), added a more
meaningful one.
2013-11-06 10:48:48 +02:00
Mihai Bazon
f4919e3a25
Do not lift sequence from right-hand side of binary operation. Fix #343
2013-11-06 10:18:28 +02:00
Mihai Bazon
b70670b69f
Fix regression after e4c5302406
...
`x * (y * z)` ==> `x * y * z` -- the better place to do this is in the
compressor rather than codegen.
2013-10-30 10:45:58 +02:00
Mihai Bazon
9dd97605bc
indentation
2013-10-30 10:44:50 +02:00
Richard van Velzen
785c6064cc
Disallow reversal where lhs has higher or equal precedence
...
Fixes #267
2013-10-29 21:37:36 +01:00
Richard van Velzen
e2daee9a65
Fix RHS concat (raised in #330 )
...
When attempting to concat the left-side of the rhs, make sure the rhs is
a string.
2013-10-26 18:44:52 +02:00
Richard van Velzen
1a5a4bd631
Fix #269
...
Shorten most primitives where possible. Also optimize some edge cases.
2013-10-24 11:08:33 +02:00
Richard van Velzen
7055af8221
Fix #280
...
The `init` of the `ForStatement` is not a `BlockStatement` before it was
descended. The descend has to happen first, and *then* the actual
checks.
2013-10-23 22:26:04 +02:00
Mihai Bazon
63d04fff69
Revert #3a81f60 for now
...
(with it some tests break and it can generate invalid output, see issue #44 )
2013-10-22 21:50:55 +03:00
Mihai Bazon
3fa9265ce4
wrap up
2013-10-09 22:15:43 +03:00
Mihai Bazon
3a81f60982
Don't drop_unused before compression.
...
Fix #280 , #282
2013-10-09 19:15:09 +03:00
Mihai Bazon
f2348dd98b
Rename clean_getters to pure_getters; add pure_funcs.
2013-10-04 13:17:25 +03:00
Mihai Bazon
8cc86fee60
add clean_getters compressor option (default false)
...
allows one to specify if `foo.bar` is considered to have side effects.
2013-10-02 19:38:01 +03:00
Mihai Bazon
88fb83aa81
minor optimization
...
unlikely to help in hand-written code:
(something() ? foo : bar) == foo ==> something()
2013-10-02 15:31:31 +03:00
Mihai Bazon
95b4507c02
Fix error in the output minifying Function("return this")()
2013-09-30 11:49:29 +03:00
Mihai Bazon
afdaeba37d
More attempts to determine when addition is associative
...
Somebody hit me with bug reports on this. :)
Refs #300
2013-09-22 15:26:10 +03:00
Mihai Bazon
037199bfe2
Actually let's move away those monsters from the evaluate function
...
ev() should do a single thing — evaluate constant expressions. if that's
not possible, just return the original node. it's not the best place for
partial evaluation there, instead doing it in the compress functions.
2013-09-22 15:00:42 +03:00
Mihai Bazon
583fac0a0f
More dirty handling of [ ... ].join() in unsafe mode
...
Close #300
2013-09-22 13:14:42 +03:00
Dan Wolff
e8158279ff
Evaluate [...].join() if possible: minor bugfix
...
Follow-up to 78e98d2 .
2013-09-22 11:34:30 +03:00
Mihai Bazon
78e98d2611
When unsafe is set, evaluate [...].join() if possible
...
Close #298
2013-09-19 18:20:45 +03:00
Dan Wolff
8d14efe818
Concatenate strings also on the right-hand side of an expression that cannot be evaluated. Fix #126
...
E.g. converts:
a+'Hello'+'World'
to
a+'HelloWorld'
2013-09-19 13:03:03 +03:00
Mihai Bazon
85b527ba3d
Disallow continue referring to a non-IterationStatement. Fix #287
...
Simplifies handling of labels (their definition/references can be easily
figured out at parse time, no need to do it in `figure_out_scope`).
2013-09-02 19:36:16 +03:00
Mihai Bazon
ed80b4a534
Move support for negate_iife in the compressor, rather than code generator
...
(the code generator doesn't maintain enough context to know whether
the return value is important or discarded)
Fixes #272
2013-08-20 17:45:52 +03:00
Michael Ficarra
d9ad3c7cbf
fixes #259 : don't unnecessarily quote object properties when --screw-ie8
2013-08-18 19:45:06 -05:00
Mihai Bazon
4c4dc2137c
Don't drop unused setter argument.
...
Fix #257
2013-08-07 12:04:58 +03:00