When purging CSS, if a non-blocklisted selector is present in an :is() or :where() selector (e.g. :is(h1, h2, h3), it is still purged from the resulting CSS.
To Reproduce
Create a basic HTML page with an <h2>Lorem ipsum</h2> element.
Create a CSS file with a declaration block of :is(h1, h2, h3) { color: red; } (placing * in front of the selector has no effect)
Run PurgeCSS on the created CSS file based on the content of the created HTML file.
Expected Behavior
The resulting styles should have :is(h1, h2, h3) { color: red; } and the <h2> should show up in red. Instead the whole declaration block is missing.
CSS is minified (Sass -> CSS with compressed output) before being fed to PurgeCSS. Tested with expanded styles, same result.
Running this as an HTML transform on an Eleventy build (v.2.0.0-canary14) which grabs a hardcoded comment line and replaces it with the purged CSS, see this gist. (this makes it a little more difficult to debug)
My workaround is to safelist :is and :where but this causes unused CSS to be kept since the selectors are used across the stylesheet.
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
chriskirknielsen commentedAug 19, 2022
Describe the bug
When purging CSS, if a non-blocklisted selector is present in an
:is()or:where()selector (e.g.:is(h1, h2, h3), it is still purged from the resulting CSS.To Reproduce
<h2>Lorem ipsum</h2>element.:is(h1, h2, h3) { color: red; }(placing*in front of the selector has no effect)Expected Behavior
The resulting styles should have
:is(h1, h2, h3) { color: red; }and the<h2>should show up in red. Instead the whole declaration block is missing.Environment
purgecss: 4.1.3
Environment: macOS v12.4, Node.js v18.6.0, npm v8.13.2
Add any other context about the problem here
CSS is minified (Sass -> CSS with compressed output) before being fed to PurgeCSS. Tested with expanded styles, same result.
Running this as an HTML transform on an Eleventy build (v.2.0.0-canary14) which grabs a hardcoded comment line and replaces it with the purged CSS, see this gist. (this makes it a little more difficult to debug)
My workaround is to safelist
:isand:wherebut this causes unused CSS to be kept since the selectors are used across the stylesheet.Code of Conduct
The text was updated successfully, but these errors were encountered: