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

Helper classes with similar names are not removed #189

Open
jsnanigans opened this issue Nov 7, 2017 · 4 comments
Open

Helper classes with similar names are not removed #189

jsnanigans opened this issue Nov 7, 2017 · 4 comments

Comments

@jsnanigans
Copy link

@jsnanigans jsnanigans commented Nov 7, 2017

Here is a very simple example that shows my problem:

var purifyCss = require("purify-css")

var html = '<div class="span-2"></div>'
var css = `
/* only .span-2 should stay */
.span-1 {width: 1vw} 
.span-2 {width: 2vw} 
.span-3 {width: 3vw}

/* .extra will be removed */
.extra {width: 100vw}
`

var purified = purifyCss(html, css, {})

the output I get is this:

/* only .span-2 should stay */
.span-1 {
  width: 1vw;
}
.span-2 {
  width: 2vw;
}
.span-3 {
  width: 3vw;
}
/* .extra will be removed */

you can try this for yourself here: https://runkit.com/jsnanigans/5a01849baa30e50011c511e7

To summarize;

The classes span-1 span-2 span-3 exist in the original css, but in my html I only use span-2. I would expect span-1 and span-3 to be removed but they persist in the purified output.

I can't imagine that I am the first to notice this, so I apologize if this is a re post.

@HapLifeMan
Copy link

@HapLifeMan HapLifeMan commented Nov 9, 2017

Hey @jsnanigans, I suggest you to use purifycss-extended instead.
I forked this repo few days ago and fix some bugs, you can find more details here!

I ran your code: https://runkit.com/haplifeman/5a0435c407085d001201410a :)

@jsnanigans
Copy link
Author

@jsnanigans jsnanigans commented Nov 9, 2017

@HapLifeMan that is awesome, thank you!

@HarwinBorger
Copy link

@HarwinBorger HarwinBorger commented Nov 15, 2017

I added a pullrequest to fix this problem by giving the opportunity to add custom regex to filter a wider range of classes #190

@HapLifeMan
Copy link

@HapLifeMan HapLifeMan commented Nov 15, 2017

Pull requests are not merged... But this is a nice feature!

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

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.