Google Closure compiler parsing error: invalid property id for `css ({float: 'left'})`

I am using the Google Closure Compiler application (command line interface). When I run it, I get the following error.

deploy/js/Home.js:40: ERROR - Parse error. invalid property id this.$images.wrapAll('<div id="slideInner"></div>').css({float:'left'}); ^ 1 error(s), 0 warning(s) 
+5
javascript google-closure google-closure-compiler
source share
2 answers

I believe what you need to do:

 {'float':'left'} 

This is because float is in the list of Java keywords reserved by JavaScript , so it cannot be used as a property name. This can no longer be a problem in new JS machines, but it can be a problem for older ones, so the compiler throws an error.

+9
source share

If you already have many soy files and you do not want to change everything in each soy file, you can pass the flag to the compiler:

 --compiler_flags="--language_in=ECMASCRIPT5" 

It worked for me.

+2
source share

All Articles