colorhook
fa3300f314
bugfix #242
2013-12-16 15:53:43 +08:00
Mihai Bazon
bd0886a2c0
semicolons
2013-12-10 20:24:27 +02:00
Mihai Bazon
248f304f02
Merge pull request #245 from ForbesLindesay/patch-1
...
Make `DefaultsError` a real `Error` object
2013-12-10 10:23:29 -08: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
8f35a363d9
AST_Catch shouldn't really inherit from AST_Scope. Fix #363
...
I hereby acknowledge that figure_out_scope has become a mess.
2013-12-05 13:30:29 +02:00
Mihai Bazon
d2190c2bf3
Properly scope catch identifier when --screw-ie8
...
Fix #344
2013-11-28 16:43:30 +02:00
Mihai Bazon
c16d538ce7
Add --noerr to turn off argument name checking
...
for now only used for keys passed to `-c` or `-b`.
2013-11-28 13:15:01 +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
63287c0e68
Workaround for Safari bug
...
Close #313
2013-10-30 13:59:59 +02:00
Mihai Bazon
c5ed2292bf
Fix parsing setters/getters (allow keywords for name).
...
The "key" property was always "set" or "get", which didn't make much sense.
Now it'll be the actual name of the setter/getter (AST_Node), and the
AST_Accessor object itself, which represents the function, won't store any
name.
Close #319
2013-10-30 11:50:22 +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
Mihai Bazon
e4c5302406
Fix output for x = 2 * (a % b / b * c)
...
(issue #337 )
2013-10-30 09:11:55 +02:00
Mihai Bazon
bea3d90771
minor
2013-10-30 09:10:56 +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
Mihai Bazon
b214d3786f
Fix typo
2013-10-29 15:53:54 +02:00
Mihai Bazon
a14c6b6574
Avoid shadowing name of function expression with function argument
...
Close #179 , #326 , #327
2013-10-29 13:18:09 +02:00
Mihai Bazon
f1b7094a57
Add "preamble" output option
...
Close #335
2013-10-29 11:09:18 +02:00
Mihai Bazon
0358e376f0
Fix codegen for when comments_before is undefined.
...
Fix #333
2013-10-28 09:39:29 +02: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
d09f0adae3
arguments outside of a function is an ordinary variable.
...
Fix #501
2013-10-17 18:20:33 +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
David Glasser
bb0a762d12
Only allow identifier start characters at the beginning of identifiers.
...
Without this fix, the following source:
x = {"\u200c": 42};
would incorrectly be converted into a quoteless key. But while \u200c is allowed
to be in identifiers, it cannot be at the beginning, as per ES5.
(For example, the SockJS client library doesn't work under uglify starting with
d9ad3c7c.)
2013-10-03 17:02:19 -07: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
83ba338bd0
Avoid printing <!-- in the output (HTML5 comment)
2013-09-06 10:10:45 +03:00
Mihai Bazon
7c10b25346
Support HTML5 comment syntax (enabled by default!)
...
See http://javascript.spec.whatwg.org/#comment-syntax
https://github.com/mishoo/UglifyJS/issues/503
https://github.com/marijnh/acorn/issues/62
2013-09-06 09:54:30 +03:00
Mihai Bazon
cb9d16fbe4
minor
2013-09-06 09:52:56 +03:00
Mihai Bazon
5d8da864c5
Fix names.
2013-09-02 19:38:00 +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
1c6efdae34
Better fix for #286
2013-09-02 11:36:48 +03:00
Mihai Bazon
b0ca896d98
Fix parsing a.case /= 1
...
Close #286
2013-09-02 11:09:54 +03:00
Mihai Bazon
78a217b94c
Fix parsing regexp after unary-prefix operator
...
++/x/.y
Fix #284
2013-09-02 09:56:27 +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
Mihai Bazon
964d5b9aa4
Don't pretend to evaluate lambdas
...
Fix #255
2013-08-04 21:44:17 +03:00
Mihai Bazon
41c627379c
Reverting "added option for dropping unused params"
...
Revert "added option for dropping unused params"
(turns out we already had the `unused` option for this.)
This reverts commit e54df2226f .
2013-07-25 18:08:36 +03:00
Dusan Bartos
e54df2226f
added option for dropping unused params
2013-07-25 17:37:47 +03:00
Forbes Lindesay
dfa395f6ff
Make DefaultsError a real Error object
2013-07-22 01:44:03 +01:00
David Glasser
b1febde3e9
Fix output for arrays whose last element is a hole: [1,,]
...
1529ab96 started to do this (by considering holes to be separate from
"undefined") but it still converted
[1,,] (length 2, last element hole, trailing comma)
to
[1,] (length 1, trailing comma)
Unfortunately the test suite doesn't really make this clear: the new test here
passes with or without this patch because run-tests.js beautifys the expected
output (in "make_code"), which does the incorrect transformation! If you make
some manual change to arrays.js to make the test fail and see the INPUT and
OUTPUT, then you can see that without this fix, [1,,] -> [1,], and with this fix
it stays [1,,].
2013-07-18 15:39:22 +03:00
Mihai Bazon
193049af19
Revert previous patch, it was no good.
2013-07-15 11:59:23 +03:00
Mihai Bazon
4a0bab0fa3
Add "position" option to parser, to specify initial pos/line/col
...
(for parsing embedded scripts)
2013-07-15 11:27:11 +03:00
Mihai Bazon
9243b0cb9d
Apply transformer to AST_VarDef's name
...
Fix #237
2013-07-14 13:24:09 +03:00
Mihai Bazon
fc9ba323c4
Fix typo.
...
Close #239
2013-07-12 09:56:58 +03:00
Mihai Bazon
02a84385a0
Don't swap binary ops when "use asm" is in effect.
...
Refs #167
2013-06-07 12:52:09 +03:00
Ville Lautanala
f29f07aabd
Escape null characters as \x00
...
Since \0 might be mistakenly interpreted as octal if followed by a
number and using literal null is in some cases interpreted as end of
string, escape null as \x00.
2013-06-03 20:46:42 +03:00
Mihai Bazon
9fc6796d2a
Add negate_iife option to the code generator.
...
See discussion in a9511dfbe5
2013-05-22 21:22:14 +03:00
Mihai Bazon
9fc8a52142
Set "global" on undeclared SymbolDef-s
2013-05-22 13:08:19 +03:00
Mihai Bazon
22a038e6a2
Fix output of statement: new function(){...};
...
Close #209
2013-05-20 08:27:37 +03:00
Mihai Bazon
ca3388cf5a
Add --expr, an option to parse a single expression (suitable for JSON)
2013-05-15 13:27:23 +03:00
Mihai Bazon
caa8896a8a
Only compress code in new Function if all arguments are strings.
2013-05-14 18:36:31 +03:00
Mihai Bazon
f64539fb76
Compress code passed to new Function if it's a constant.
...
Only for `--unsafe`.
Close #203
2013-05-14 10:47:06 +03:00
Mihai Bazon
d56ebd7d7b
Fix a["1_1"]
...
Close #204
2013-05-14 10:42:34 +03:00
Mihai Bazon
a9511dfbe5
Use the negation hack rather than parens for a toplevel function expression call
...
(only in !beautify mode)
2013-05-09 08:58:47 +03:00
Mihai Bazon
064e7aa1bb
Fix is_assignable
...
(not likely to be noticed, it's only used in `strict` parse mode)
2013-05-09 08:44:24 +03:00
Mihai Bazon
11e24d53a1
Fix property names
...
Close #199
2013-05-08 22:37:48 +03:00
Mihai Bazon
a6ed2c84ac
Better fix for equality of typeof ... against "undefined"
2013-05-08 16:22:48 +03:00
Justin Lau
a1958aad56
Fixed typeof undefined optimization and updated related test case to
...
accomodates the sort behaviour changes made in commit
mishoo/UglifyJS2@aebafad41e .
Signed-off-by: Justin Lau <justin@tclau.com>
2013-05-08 16:22:48 +03:00
Justin Lau
9af2bbffde
Fixed dot properties not optimizing unicode identifiers. Signed-off-by: Justin Lau <justin@tclau.com>
2013-05-07 14:20:19 +03:00
Justin Lau
1e3bc0caa0
Fixed dot property issue with invlid identifier names.
...
Signed-off-by: Justin Lau <justin@tclau.com>
2013-05-05 22:27:43 +08:00
Mihai Bazon
9794ebf88c
Workaround for missing prefix in UnaryExpression generated by Esprima
...
See #193
2013-04-29 15:03:52 +03:00
Michael Ficarra
5af144522a
fixes #189 : use dotted member access when --screw-ie8 option given
2013-04-20 15:11:05 -05:00
Roman Bataev
4b818056cf
Fix typeof evaluation for regex and function
2013-04-03 22:34:38 -04:00
Vladimir Zhuravlev
37d7cb8565
Quote objects with numeric keys
2013-03-31 19:52:28 +03:00
Mihai Bazon
a869b854fa
Don't use \xYY for identifiers
...
Fix #173
2013-03-31 13:36:22 +03:00
Andreas Lind Petersen
81f5efe39a
Output, to_ascii: Escape non-ascii chars with \xnn instead of \unnnn whenever possible.
2013-03-31 13:36:22 +03:00
Michał Gołębiowski
75f0bbe6e8
renamed --screw-ie to --screw-ie8, documented it in README.md, indicated it doesn't break IE9+
2013-03-25 17:03:21 +01:00
Jake Harding
478bf4dbdd
Add support for enclose option. Closes #139 .
2013-03-24 11:11:23 +02:00
Mihai Bazon
e0f67baf2d
Don't print the warning on parse error, just throw a JS_Parse_Error.
...
Fix #159
2013-03-24 00:57:35 +02:00
Mihai Bazon
b14d3df3d2
Keep legit code working even when --screw-ie is not passed.
...
Previously:
Without `--screw-ie`, UglifyJS would always leak names of function
expressions into the containing scope, as if they were function
declarations. That was to emulate IE<9 behavior. Code relying on this
IE bug would continue to work properly after mangling, although it would
only work in IE (since other engines don't share the bug). Sometimes
this broke legitimage code (see #153 and #155 ).
With `--screw-ie` the names would not be leaked into the current scope,
working properly in legit cases; but still it broke legit code when
running in IE<9 (see #24 ).
Currently:
Regardless of the `--screw-ie` setting, the names will not be leaked.
Code relying on the IE bug will not work properly after mangling.
<evil laughter here>
Without `--screw-ie`: a hack has been added to the mangler to avoid
using the same name for a function expression and some other variable in
the same scope. This keeps legit code working, at the (negligible,
indeed) cost of one more identifier.
With `--screw-ie` you allow the mangler to name function expressions
with the same identifier as another variable in scope. After mangling
code might break in IE<9.
Oh man, the commit message is longer than the patch.
Fix #153 , #155
2013-03-22 18:04:46 +02:00
Mihai Bazon
9b1a40dfc3
Support mangling toplevel names
...
Close #127
2013-03-13 09:44:06 +02:00
Mihai Bazon
e4b078cff7
Disable unsafe by default
...
Close #147
2013-03-11 00:04:31 +02:00
Mihai Bazon
aebafad41e
Fix reordering comparisons
...
Close #143
2013-03-04 10:06:01 +02:00
Mihai Bazon
26746ce316
Add --screw-ie option
...
For now the implication is that UglifyJS will not leak a function
expression's name in the surrounding scope (IE < 9 does that).
(ref. mishoo/UglifyJS#485 )
2013-03-02 14:28:34 +02:00
Mihai Bazon
dac6efb43d
Drop last default: if it's the last branch and empty
...
Close #141
2013-03-01 13:12:03 +02:00
Mihai Bazon
8880f4824c
Compress boolean constants after evaluation
...
Close #137
2013-03-01 10:26:06 +02:00
Mihai Bazon
3a591c43fe
Fix compressing do {...} while (false)
...
It's not safe to transform it to {...} because the body might contain
`break`. The solution could be more elaborate (detect if body contains
`break`) but I don't think it's worth the trouble.
Close #129
2013-02-19 18:12:19 +02:00
Mihai Bazon
916faf0a48
Force space after literal regexp when used in "instanceof" or "in"
...
Close #118
2013-02-06 11:57:59 +02:00
Mihai Bazon
f36e4e9a78
Give up evaluating (unary-prefix '-' 0)
...
Close #117
------
JS, WHY YOU SUCK SO BADLY? ;-(
2013-02-06 11:51:09 +02:00
Mihai Bazon
fdf8b5eb71
Fix parens for NaN
...
Close #116
2013-02-06 11:38:29 +02:00
Mihai Bazon
de7ec7f1b7
Fix parens for negative numbers
...
Close #115
2013-02-06 11:36:04 +02:00
Mihai Bazon
3c8a0bdff4
Fix parens for AST_New
...
Close #114
2013-02-06 11:28:49 +02:00
Mihai Bazon
9e8ba27dcd
Fix handling of constants
...
Close #113
2013-02-06 11:15:31 +02:00