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]: Greedy advanced attribute CSS selectors not applying #913

Open
1 task done
spacedawwwg opened this issue May 12, 2022 · 0 comments
Open
1 task done

[Bug]: Greedy advanced attribute CSS selectors not applying #913

spacedawwwg opened this issue May 12, 2022 · 0 comments
Labels

Comments

@spacedawwwg
Copy link

Describe the bug

A bug

To Reproduce

CSS

.c-card {
  color: black;
}

[class*="c-card--ghost"] {
  color: red;
}

[class*="c-card--ghost"].c-card--horizontal {
  color: green;
}

[class*="c-card--ghost"]:not(.c-card--horizontal.has-media) {
  color: pink;
}

.c-card--ghost-dark {
  background: blue;
}

PurgeCSS Config

{
  content: [path.resolve(dist, '**/*.html'), path.resolve(dist, '**/*.js')],
  css: [path.resolve(assets, '*.css')],
  safelist: {
    standard: ['body', 'html', 'img', 'a', ':lang'],
    greedy: [/^is-/, /^has-/, /^js/, /^no-js/, /^data-/, /^disabled/, /^c-card/],
  },
  variables: false,
}

Expected Behavior

Expected CSS after purge

.c-card {
  color: black;
}

[class*="c-card--ghost"] {
  color: red;
}

[class*="c-card--ghost"].c-card--horizontal {
  color: green;
}

[class*="c-card--ghost"]:not(.c-card--horizontal.has-media) {
  color: pink;
}

.c-card--ghost-dark {
  background: blue;
}

Actual CSS after purge

.c-card {
  color: black;
}

[class*="c-card--ghost"].c-card--horizontal {
  color: green;
}

[class*="c-card--ghost"]:not(.c-card--horizontal.has-media) {
  color: pink;
}

.c-card--ghost-dark {
  background: blue;
}

The selector [class*="c-card--ghost"] is purged even with a greedy selector of /^c-card/

Environment

OS: macOS
Node: 16
Package: purgecss@4.1.3

Add any other context about the problem here

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
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

1 participant