robnyman / domassistant

Automatically exported from code.google.com/p/domassistant
1 stars 0 forks source link

Javascript Compression leads to error #28

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I added a javascript compression and an error occures on line 776 of dom 
assistant lib:

var uniqueId = 1, data = [], expando = "_da" + +new Date();

==> invalid increment operator

removing the second "+" solves the problem:

var uniqueId = 1, data = [], expando = "_da" + new Date();

Original issue reported on code.google.com by robert.w...@googlemail.com on 13 Aug 2010 at 10:03

GoogleCodeExporter commented 9 years ago
It's the unary + operator. It has the same effect as

new Date().getTime()

i.e. returning the current date as a number.

Original comment by chengh...@gmail.com on 13 Aug 2010 at 2:23

GoogleCodeExporter commented 9 years ago
Ok, so the problem is solved by changing the line to:

var uniqueId = 1, data = [], expando = "_da" + new Date().getTime();

If compression is enabled, the whitespaces are removed, so that "_da" + +new 
Date();" get's to "_da"++new Date();" what leads to an error.

Original comment by robert.w...@googlemail.com on 13 Aug 2010 at 2:40

GoogleCodeExporter commented 9 years ago
May I ask which compressor do you use?

The official compressed version uses YUI Compressor, which is smart enough to 
leave a space between the pluses.

Also, you'll need to add the /*@cc_on!@*/ back into the code, or your 
compressed DA won't work properly in IE.

Original comment by chengh...@gmail.com on 13 Aug 2010 at 2:57