feat: Support more CSS selector attributes #16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First of all, love the plugin. Saw it recommended here: www.youtube.com/watch?v=PN6tjeQfxRc, and now use it a lot.
Problem
I really wanted to have the chance to match not only on prefixes but suffixes and even any regular expression too. There seems to be some interest from others too as seen in #5.
Changes
So, I went ahead and implemented that. I basically saw that CSS supports multiple selector attributes: https://www.w3.org/TR/selectors/#attribute-substrings. So I just added a new
selectorproperty toBlockStylesto choose among the 4 that seemed the most relevant (exact match, prefix, suffix, and substring).This means that with a configuration like this:

It's now possible to achieve this result:

Naturally, the new settings are not backwards compatible, so I also added a bit of code to handle mapping old settings to the new settings. Would really like somebody to test/review this too, just to have a second confirmation that everything works fine (I tested in with my own settings and they worked fine).
Unfortunately, I couldn't get the plugin setup for development without bumping a bunch of dependencies, so I bundled that together with this change.
TODO
Maybe more selectors could be added later? I am not super familiar with the CSS spec, pretty much just reading through the docs the first time now.
Personally, I would like to be able to group a bunch together, to shorten my settings when repeated styles happen.
I hope these changes are well received, if not, feel free to close this PR! Thank you for your time.