Hoist functions when reversing if (x) return; ... vs. if (!x) ...#1053
Hoist functions when reversing if (x) return; ... vs. if (!x) ...#1053mishoo merged 3 commits intomishoo:masterfrom
Conversation
|
This PR unbreaks the jQuery code I mentioned #1052 and adds only 6 bytes gzipped, looks good to me from that perspective. 👍 @gibson042 you had some doubts about this approach, could you elaborate? |
|
Actually, as @kzc pointed out in jquery/jquery#3075 (comment), it'd be good to have test cases with a single function declaration as well as then the braces are stripped which may result in a different output. Could you add such test cases? |
|
@mgol Actually my point was that uglify's parser is not nearly as strict as a full-fledged JS linter, and generally would not be able to catch errors in parsing its own output. An independent parser would be better to validate the output. Just to be clear are you asking for an uglify parser change to fail the parse if functions are declared within blocks of statements? If so, a new issue should be opened for that. |
|
@kzc I meand that I'd like another test case where the original source has only one function declarations to make sure that it's not converted to |
|
PR looks good to me. |
|
LGTM! |
Fixes #1052