Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

jquery - Internet Explorer, Closure Compiler and Trailing Commas

I'm using html5boilerplate build script and when minifying the scripts (which uses Google Closure Compiler)

I'm getting this error

-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] 

             ^

But the code DOES work in IE 8 if run uncompiled.

This is the code

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

How can I make this code pass Compulsure Compiler?

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Remove the superfluous last comma from your object literal:

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.

As the Closure compiler says, literals with such trailing commas cannot be parsed by some browsers.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...