wpbasti/jasy — Issue #9: Unused object generates invalid JS code
Author: csakatoku
Created: 2012-02-11 14:39:14+00:00
State: open

Unused object which has a function in its properties generate invalid JS code.

The following code

core.Class("p.MyClass", {
construct: function() {
var obj = {
method: function() {
return "result";
}
};
}
});

is compressed to the following code (beautified to make it readable).

core.Class("p.MyClass", {
construct: function () {
{
method: function () {
return "result"
}
}
}
});

And this code causes an error saying "Uncaught SyntaxError: Unexpected token (".

I'm using the latest Jasy (f86953ef31), but it's reproducible on Jasy==0.4.6.

Note that the compressed output code is generated by storeCompressed function with the default optimazation options.

compressedCode = storeCompressed("build/app-%s.js" % permutation.getChecksum(), classes,
permutation=permutation, bootCode="new p.MyClass();")