Commit Graph

1811 Commits

Author SHA1 Message Date
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
Mihai Bazon 719a8fd102 Ugly hack to print comments before return/throw statements
Close #112
2013-02-05 19:11:39 +02:00
Mihai Bazon a5b209470c Fix end token for Assign nodes 2013-02-01 13:32:15 +02:00
Richard Gibson 522566ea80 Fix #105: property comparison to undefined is not always safe 2013-01-23 23:52:04 -05:00
Mihai Bazon faa354f5ca [AST_Hole] the print function can be a no-op. 2013-01-17 11:36:10 +02:00
David Glasser 1529ab965a Fix output for arrays containing undefined values.
1b6bcca7 was a first attempt at this. That commit made Uglify stop replacing
holes with undefined, but instead it started replacing undefined with
holes. This is slightly problematic, because there is a difference between a
hole and an undefined value. More problematically, it changed [1,undefined] to
[1,] which generally doesn't even parse as a hole (just as a trailing comma), so
it didn't even preserve the length of the array!

Instead, parse holes as their own special AST node which prints invisibly.
2013-01-17 11:36:10 +02:00
Mihai Bazon f0909bdc8f Handle String() with no arguments.
Fix #91
2013-01-17 11:01:38 +02:00
Mihai Bazon 6b14f7c224 Fix handling of labels in nested scopes 2013-01-04 14:17:33 +02:00
Mihai Bazon 83a4ebfedc Implement -m sort=true
close #83
2013-01-02 12:39:00 +02:00
Mihai Bazon 9916d0e547 Accept string or number as name of an accessor.
[not sure I'm happy about this fix]

Reference mishoo/UglifyJS#478
2012-12-22 01:24:04 +02:00
Mihai Bazon 31c4a37e37 Optimize new Array(1, 2, 3) → [1, 2, 3]
Close #74
2012-12-21 21:04:35 +02:00
Mihai Bazon 08219f0cee Fix output when semicolons is off.
(need to force a semicolon for the empty body of an `if`)

Close #72
2012-12-21 11:57:08 +02:00
Mihai Bazon c4993e1e5c Small cleanup 2012-12-12 11:51:55 +02:00
Mihai Bazon 98978fc827 Add proper parens in "NoIn" expressions.
fix #60.
2012-12-06 12:27:57 +02:00
Mihai Bazon 16430acc1f small improvement on merging assignments into hoisted vars 2012-12-05 13:14:49 +02:00
Mihai Bazon 320c110b33 When hoisting variables, try to merge in assignments that follow. 2012-12-05 12:30:25 +02:00
Mihai Bazon 5cc90db7d0 Don't messup compressor stack while optimizing Switch
Fix #59
2012-11-30 11:16:09 +02:00
Mihai Bazon 13c4dfcabd fix #55 2012-11-24 10:02:08 +02:00
Mihai Bazon 4f555e2232 fix for https://github.com/mishoo/UglifyJS/issues/474 2012-11-23 10:20:00 +02:00
Mihai Bazon 089ac908b7 fix #51 2012-11-18 17:37:45 +02:00