Idered / cssParentSelector

CSS4 parent selector based on jQuery
214 stars 38 forks source link

Minified CSS #17

Open Shakarhaba opened 11 years ago

Shakarhaba commented 11 years ago

The code doesn't support minified css code. On line 81 you replace every single semicolon with !important; this procedure is a problem with minified css code.

Line 81: declarations = declarations.replace(/;/g, ' !important;');

Example CSS Markup (Minified): div.test!>span:hover{background:red}

Problem: There is no ending semicolon, as there is just one rule (When there is more than one rule the last one still misses the ending semicolon) being set the semicolon is trivial and removed by every single minifier.

Even though the CPS# class is being added correctly on hover, the styling rules are not set as are being overridden by the default ones.

Shakarhaba commented 11 years ago

I don't know much about regex, I solved it by doing:

declarations = declarations.replace(/(?:[\s+]?;?[\r+]?[\s+]?})/g, '!important}'); declarations = declarations.replace(/;/g, ' !important;');

I'm sure there is a way to do it in a single line of code.