matthiasmullie / minify

CSS & JavaScript minifier, in PHP. Removes whitespace, strips comments, combines files (incl. @import statements and small assets in CSS files), and optimizes/shortens a few common programming patterns.
https://matthiasmullie.github.io/minify/
MIT License
1.96k stars 310 forks source link

Nth-child with spaces inside gets broken #426

Open roby65 opened 2 months ago

roby65 commented 2 months ago

We have this code in our css:

nth-child(1 of :not([class*=hero]))

This gets minified to:

nth-child(1of :not([class*=hero]))

Breaking it.

The code that breaks this is in CSS.PHP line 757:

$content = preg_replace('/:(' . implode('|', $pseudos) . ')\(\s*([+-]?)\s*(.+?)\s*([+-]?)\s*(.*?)\s*\)/', ':$1($2$3$4$5)', $content);