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 · 2 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 · 2 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

purgecss@6.0.0-alpha.0

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
  ],
}

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

3 participants