Skip to content

[Bug]: Most pseudo-classes incorrectly purged when there is no selector before it #1282

@xNyfPtx

Description

@xNyfPtx

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

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions