admin管理员组

文章数量:1313121

I'm using Google Closure Compiler application (mand line interface). When I run it I get the below 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)

I'm using Google Closure Compiler application (mand line interface). When I run it I get the below 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)
Share Improve this question edited Sep 23, 2012 at 18:45 Christopher Peisert 24.2k3 gold badges101 silver badges126 bronze badges asked Jul 7, 2011 at 14:03 ChapsterjChapsterj 6,63521 gold badges73 silver badges124 bronze badges 2
  • Have you tried putting the key in quotes ? .css({'float':'left'}) ? – Gabriele Petrioli Commented Jul 7, 2011 at 14:10
  • Note that I've seen unquoted keywords used as this cause errors in IE, so it's a good thing to fix anyway :) – Michael Mior Commented Jul 7, 2011 at 14:16
Add a ment  | 

2 Answers 2

Reset to default 9

I believe that you need to do:

{'float':'left'}

This is because float is on the list of Java keywords reserved by JavaScript, so it cannot be used as a property name. This may no longer be an issue in newer JS engines, but it can be a problem in older ones, which is why the Compiler yields an error.

If you already have tons of soy files, and don't want to change everthing in every soy file, you can pass a flag to the piler:

--piler_flags="--language_in=ECMASCRIPT5"

It worked out well for me.

本文标签: javascriptGoogle Closure Compiler parse error invalid property id for css(float39left39)Stack Overflow