Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: :where is incorrectly purged when it is a child of :not #1197

Open
1 task done
AdrianGonz97 opened this issue Dec 3, 2023 · 3 comments
Open
1 task done

[Bug]: :where is incorrectly purged when it is a child of :not #1197

AdrianGonz97 opened this issue Dec 3, 2023 · 3 comments
Labels

Comments

@AdrianGonz97
Copy link
Contributor

Describe the bug

When the pseudo-class :where is a child of :not and the selector inside of :where is an "unused" selector, it is incorrectly purged.

I would also assume that :is is also affected by this as both pseudo-classes are treated similarly.

To Reproduce

.root :not(:where(.unused)) {
    color: purple;
}

Expected Behavior

The rule should not be purged.

Environment

[email protected]

Add any other context about the problem here

n/a

Code of Conduct

  • I agree to follow this project's Code of Conduct
@zokkis
Copy link

zokkis commented Apr 4, 2024

a hack is to safelist a regex like /:not.+/

@meduzen
Copy link

meduzen commented Apr 5, 2024

a hack is to safelist a regex like /:not.+/

As there’s the same issue (#978) for multiple pseudo-selectors, what I do is the following:

const purgeCssOptions = {
  safelist: [
    /:is/, // https://github.com/FullHuman/purgecss/issues/978
    /:where/, // https://github.com/FullHuman/purgecss/issues/978
    /:not/, // https://github.com/FullHuman/purgecss/issues/1197
  ],
}

@ogbotemi-2000
Copy link

PurgeCSS is clearly lacking more ways than this. When I used it to audit TailwindCSS against a html file, it totally ignored the utility classes for media query breakpoints: 8sm, md, lg, xl, 32xl*

To cater for my needs I created a thorough and concise alternative available here: https://www.npmjs.com/package/rmrf-css.
I'm sure it will provide the expected output you seek.
Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants