Todo list
known issues and future improvements.
-
Make JSXS be compatible with JavaScript 1.7 and E4XIntroduce let and yield statements.enhancement; priority 1/5.
-
Concat variable declaration in same function (if final is more short)feature; priority 4/5.
var a = 'a'; a += 'a'; var b = a;
to :var a = 'a',b; a += 'a'; b = a;
-
Detect redundant value assigned by reference for add variable who factorize thatfeature; priority 4/5.
var h = document.location.host, q = document.location.search, i = document.getElementById('myid');
to :var a = document, b = a.location, h = b.host, q = b.search, i = a.getElementById('myid');
-
Remove bloc statement ({...}) but leave semicolon in if .. else and some others statementsfeature; priority 3/5.
if (condition) { statement1; } else { statement2; }
to :if (condition) statement1; else statement2;
-
Parse "with" statementfeature; priority 2/5.
with (object) { object.attribute... ... }
Actualy all the codes that it reports probably a syntax error. -
Reduce varname in "catch" statementenhancement; priority 1/5.
try { ... } catch (myvar) { myvar... }
to :try { ... } catch (a) { a... }
-
Fix option "compatibility"This doesn't work if shrink option is desactivated.bug; priority 3/5.
-
Convert object property string definedfeature; priority 3/5.
var a = { 'test': 69, "69": 'test' };
to :var a = { test: 69, 69: 'test' };
-
Reduce condition if true valuefeature; priority 3/5.
var a = 'something'; if (a == true) { ... }
to :var a='something';if(a){...}
andif (true) { ... }
to :if (1) {...}
-
Advanced reduce logical condition according to operator precedence and priorityfeature; priority 2/5.
while ( (a = (b || true)) || (b != (a > 3) && b < 4)) { ... }
to :while ( (a = b || true) || b != a > 3 && b < 4) { ... }
-
Detect redundant string value and assign to variable (if final is more short)feature; priority 3/5.
if(a = "a value string" && b = "a value string"){}
to :var c = "a value string"; if(a = c && b = c){}
-
Remove semicolumn between do-while when compatibility option is activedThis produce a syntax error, result is :bug; closed in v0.7.1
do { ... }; while (...)
-
make a CLIphp jsxs-cli.php -f script.jsfeature; priority 5/5.
Great!
You could add to your "todo list" :
fartorise string is necessary
like :
if(typeof a = "string" && typeof b = "string")
>> to :
var c = "string"
if(typeof a = c && typeof b = c)
At first, the variable name generation fails on a 2-digits generation.
For example, it starts at "be" instead of "ba" and go out of usable character range (attempt to use variables like "b€" or "b{").
This can be quickly fix on the line 535 of Jsxs.php file:
( $c < 36 ? chr($c + 97) : chr($c + 65) )
by using this code:
( $c < 36 ? chr($c + 87) : chr($c + 29) )
You see that it is just a incorrect range usage, nothing else...
Also, the second bug is really more complicate.
The compatibility option break some code (especially the jQuery library) by adding a semi-colon where it should not.
I have found it on some declarations like "{code}(),", that turns to "{code};(),".
Hopefully, this option can be deactivated and everything works fine without.
NOTE: on jQuery 1.5.2, look for the string:
return d}(),e="then done fail isResolved
You will see than after transformation it becomes:
return d};(),e="then done fail isResolved
... oups
Thanks for this nice tool.
Loops
I'll test it and integrate it quickly.