You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To differentiate the case of :not(.c1, .c2){} that can be minimized to :not(.c1,.c2){} and :not(.c1 .c2){} that cannot be minimized, we could verify the presence of a ',' in the selector.
Well, the exact CSS4 spec for :not states that the :not() pseudo-class requires a comma-separated list of one or more selectors as its argument. The list must not contain another negation selector or a pseudo-element.
According to CSS 3, only simple selector are valid in the argument of :not() pseudo-class and <attribute-selector> is a valid <simple-selector>.
According to CSS 4 grammar, <attribute-selector> is a valid <selector-list>.
So, in theory, the case that you show is possible.
Did you differentiate a <selector-list> and a <complex-selector> in the selector parser ? I didn't find if clean-css has implemented a selector parser or not.
We may have a look at css-tree for the selector parsing part.
Activity
abarre commentedon Feb 25, 2018
I dig into this issue. The space is removed here
https://github.com/jakubpawlowicz/clean-css/blob/f2c633791f6f81d66223fb26c1c6571b6c65430b/lib/optimizer/level-1/tidy-rules.js#L115
Adding
stripped.push(character);will break https://github.com/jakubpawlowicz/clean-css/blob/f2c633791f6f81d66223fb26c1c6571b6c65430b/test/fixtures/issue-241.css#L1abarre commentedon Mar 5, 2018
To differentiate the case of
:not(.c1, .c2){}that can be minimized to:not(.c1,.c2){}and:not(.c1 .c2){}that cannot be minimized, we could verify the presence of a ',' in the selector.jakubpawlowicz commentedon Mar 5, 2018
Can you put attribute rule inside not, e.g.
:not(.c1[data-id="1,2,3"] .c2)? But in general it's good idea to go that way.abarre commentedon Mar 5, 2018
Well, the exact CSS4 spec for
:notstates that the :not() pseudo-class requires a comma-separated list of one or more selectors as its argument. The list must not contain another negation selector or a pseudo-element.According to CSS 3, only simple selector are valid in the argument of :not() pseudo-class and
<attribute-selector>is a valid<simple-selector>.According to CSS 4 grammar,
<attribute-selector>is a valid<selector-list>.So, in theory, the case that you show is possible.
abarre commentedon Mar 5, 2018
Did you differentiate a
<selector-list>and a<complex-selector>in the selector parser ? I didn't find if clean-css has implemented a selector parser or not.We may have a look at css-tree for the selector parsing part.
jakubpawlowicz commentedon Mar 6, 2018
Thanks @abarre for having a closer look at it.
clean-css doesn't have a selector parser, just simple optimizer - see https://github.com/jakubpawlowicz/clean-css/blob/master/lib/optimizer/level-1/tidy-rules.js, as I haven't found a good reason to have it.
tobiasvielmetter commentedon Aug 21, 2019
I have the same issue with
being minified to:
Which is not the same selector. Any suggestions how to circumvent this?
Adds test case for #996.
jakubpawlowicz commentedon Jan 20, 2021
Fixed in e651f24
lluerich commentedon Mar 4, 2021
I just ran into the same issue and a quick check on https://jakubpawlowicz.github.io/clean-css/ running v5.1.1. doesn't seem to have solved the issue.
e.g. the example code that @tobiasvielmetter provided still produces the same minified output.
jakubpawlowicz commentedon Mar 5, 2021
Hmmm, you are right @lluerich. I have no idea how it slipped through the tests. Let's reopen it.
Fixes #996 - outstanding issue with spaces removed inside pseudoclasses.
jakubpawlowicz commentedon Mar 19, 2021
This time it is fine, please see @tobiasvielmetter example in test cases - 64d8c27#diff-893825b7389c9d5a4f8db929537b0649c75836c0cb03446de8fb1d2716e1ddffR273
Sorry for trouble with extra testing & reporting.