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

岁酱吖の 提交于 2019-12-01 17:14:02

问题


I'm using Google Closure Compiler application (command 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)

回答1:


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.




回答2:


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 compiler:

--compiler_flags="--language_in=ECMASCRIPT5"

It worked out well for me.



来源:https://stackoverflow.com/questions/6611867/google-closure-compiler-parse-error-invalid-property-id-for-cssfloatleft

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!