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

RegExp patterns for dynamicAttributes #895

Open
yhatt opened this issue Apr 15, 2022 · 0 comments
Open

RegExp patterns for dynamicAttributes #895

yhatt opened this issue Apr 15, 2022 · 0 comments
Milestone

Comments

@yhatt
Copy link

yhatt commented Apr 15, 2022

Is your feature request related to a problem? Please describe.
When creating Web apps, I often use data attribute to pass the value generated from server to JS through HTML. For keeping critical styles that are depending on attribute values, I have thought it is useful to make a solution to mark a bunch of attributes that have the same rule, as "dynamic".

Describe the solution you'd like
Allow RegExp patterns in dynamicAttributes, such as [/^data-.+/].

Describe alternatives you've considered
safelist: It works well enough to keep selectors for dynamic attributes. However, sometimes need to want more fine tuning. (e.g. purge styles for the custom element such as <data-table> provided by a framework, and keep user styles for data- attribute)

Additional context
Currently dynamicAttributes just ignores RegExp. If it was supported, the consistency of PurgeCSS configuration would be improved too.

Another useful case of RegExp pattern is /^.+$/. It can treat all attribute selectors as dynamic, and protect from unexpected purging.

@Ffloriel Ffloriel added this to the 5.0.0 milestone May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants