keithclark / selectivizr

selectivizr is a JavaScript utility that emulates CSS3 pseudo-classes and attribute selectors in Internet Explorer 6-8.
1.71k stars 247 forks source link

Problem with latest minified version not working #37

Closed somatonic closed 11 years ago

somatonic commented 12 years ago

When I use the unminified it works again. Any thoughts?

msheakoski commented 12 years ago

The problem is with the /*@cc_on!@*/ comment in this part of the script:

// If browser isn't IE, then stop execution! This handles the script
// being loaded by non IE browsers because the developer didn't use
// conditional comments.
if (/*@cc_on!@*/true) return;

What happens is that most minifiers strip out comments, causing the expression to evaluate to true, which causes selectivizr to stop executing and return.

If you change the if statement to:

if (/\bMSIE\b/.test(navigator.userAgent) === false) return;

then minifying should work.

BioNuc commented 11 years ago

I think you should accept GMFlash pull request because I faced the same issue here and it is really annoying It took me days debugging what is the problem until I found that this was the reason

I really appreciate the good work done in this library so thats why I wanna have this fix to everyone rather than just me

Thanks

gabetax commented 11 years ago

If you're putting selectivizr in a Ruby on Rails project using sprockets/the asset pipeline, this issue is going to affect you once you push your code to production and rake assets:precompile runs the minification. The best work around is to replace selectivizr with the version from the (still unaccepted) pull request @ https://github.com/keithclark/selectivizr/raw/50819b02128be5e381ba236fcab7a001116492f7/selectivizr.js

keithclark commented 11 years ago

Fixed in 15f8bf23df7e014651c11f5fbcb19809273172fd