Swaagie / minimize

Minimize HTML
MIT License
162 stars 18 forks source link

Conditional IE comments bug #29

Closed jlgrall closed 9 years ago

jlgrall commented 9 years ago

Hi, I am using your minimizer through https://github.com/jonathanepollack/gulp-minify-html and I found a bug.

With the option conditionals: true, I have an error in the output.

Input:

<!--[if lt IE 9]>      <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->

Output:

<!--[if lt IE 9]>      <html class="no-js lt-ie9"> <![endif]--><html class=no-js lang=en>

The second conditional is not retained, probably because it is mixed with HTML comments to hide the conditional to other browsers.

Also note that the spaces should be removed.

(This is code is used in http://html5boilerplate.com/, see the output with "IE classes".)

Swaagie commented 9 years ago

A quick fix for now would be keeping comments as well, e.g. the option comments: true. That said I wasn't aware of this variation and will look it up and possibly fix it.

Swaagie commented 9 years ago

Legit sitepoint has a good reference http://www.sitepoint.com/web-foundations/internet-explorer-conditional-comments/ see the downlevel releaved conditional comments section. It's a hack to keep code valid, will fix asap

jlgrall commented 9 years ago

Interesting read, and thx for the quick fix. I don't need it as I am not really targeting old IE, but thx.

Good luck with the regexp.

Swaagie commented 9 years ago

simplified the comments parser and released as v1.1.0, its actually nice when reducing code leads to better output :)

jlgrall commented 9 years ago

Thanks, and yep, good job.

I will test it in a few days.