[Bug]: Most pseudo-classes incorrectly purged when there is no selector before it
Author: xNyfPtxCreated Oct 4, 2024Updated Jul 8, 2026
Labelsbug
Describe the bug
It removes psedo-classes without a selector before it.
/* This will be removed and purged incorrectly */
:hover { }
:not(:hover) { }
:where() {}
:where(:hover) {}
etc..
/* This will not be removed and purged incorrectly */
*:hover { }
.class:hover { }
#id:hover { }
[attribute]:hover { }
::after { }
::before { }
and etc.
It doesn't affect pseudo-elements like ::after but affects pseudo-classes. There are some exceptions which are :root but I haven't found more exceptions beyond that
The bug can be sourced from https://purgecss.com/extractors.html
Does not consider special characters such as
@, :, /
To Reproduce
Already described
Expected Behavior
I was expecting them to be not removed in the CSS
Environment
OS: Linux Mint; Package: purgecss; Version: 6.0.0;
Add any other context about the problem here
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
Source: FullHuman/purgecss