blickly / closure-compiler-issues

0 stars 0 forks source link

Array Join Munged Incorrectly #106

Closed blickly closed 9 years ago

blickly commented 9 years ago
$.fn.hasClass = function(selector) {
    return ( this.length > 0 ? 
                !( ( ['', this[0].className, ''].join(' ') ).indexOf( ['', selector, 
''].join(' ') ) == -1 )
                : false );
};

munges into

$.fn.hasClass=function(a){return this.length>0?
(""+this[0].className).indexOf(""+a)!=-1:false};

which is not identical. Looks like there might be an issue with join and ' '.

Original issue reported on code.google.com by zachleatherman on 2010-02-09 00:51:48

blickly commented 9 years ago
(No text was entered with this change)

Original issue reported on code.google.com by acleung on 2010-02-09 02:25:31

blickly commented 9 years ago
Looks like this is much more serious than I thought.  Anything with join is destroyed.

[1,2,3].join('abcdef');

munges into nothing.

Original issue reported on code.google.com by zachleatherman on 2010-02-09 13:51:30

blickly commented 9 years ago
A simpler example would be:
var a = ['', 'a', ''].join(' ');

which evaluates to
" a "

But the compiler converts the code to 
var a="a ";

Original issue reported on code.google.com by outofthemold on 2010-02-09 15:02:26

blickly commented 9 years ago
I fixed it last night. It'll be pushed out in the next release.

Original issue reported on code.google.com by acleung on 2010-02-09 17:01:55

blickly commented 9 years ago
This issue was closed by revision r99.

Original issue reported on code.google.com by Nicholas.J.Santos on 2010-02-09 21:33:13