Internet Explorer,Closure Compiler和Trailing Commas

Jua*_*cio 5 jquery build-script google-closure google-closure-compiler html5boilerplate

我正在使用html5boilerplate构建脚本并在缩小脚本时(使用Google Closure Compiler)

我收到了这个错误

-js.all.minify:
     [echo] Minifying scripts
     [copy] Copying 3 files to /Users/Username/Desktop/Web/intermediate/js
    [apply] /Users/Juan/Desktop/Web/js/plugins.js:117: ERROR - Parse error. Internet Explorer has a non-standard intepretation of trailing commas. Arrays will have the wrong length and objects will not parse at all.
    [apply]                 }, { duration: 727 })
    [apply] 

             ^
Run Code Online (Sandbox Code Playgroud)

但是,如果运行未编译,代码将在IE 8中运行.

这是代码

anim1.animate({
                    'left': '+=32px',
                    'filter': 'alpha(opacity=100)',
                    '-moz-opacity': '1',
                    '-khtml-opacity': '1',
                    'opacity': '1',
                }, { duration: 727 })
Run Code Online (Sandbox Code Playgroud)

如何让这段代码通过Compulsure Compiler?

谢谢

Fré*_*idi 10

从对象文字中删除多余的最后一个逗号:

anim1.animate({
    'left': '+=32px',
    'filter': 'alpha(opacity=100)',
    '-moz-opacity': '1',
    '-khtml-opacity': '1',
    'opacity': '1'      // <-- No comma here.
}, { duration: 727 });  // <-- I'd also suggest a semicolon there.
Run Code Online (Sandbox Code Playgroud)

正如Closure编译器所说,某些浏览器无法解析具有此类尾随逗号的文字.