Always use restrictTo
I suggest to always have allow-list of states, because right now we prefix :where(), :not() and many other CSS functions like this.
Even if we blacklist when, new will be added in the future. It is more likely to add new non-interactive pseudo-state.
Good idea! I think that going for an allow-list approach makes sense.
In this case though we shouldn't use restrictTo in my opinion because if a user wants to add a pseudo class to the default ones they will have to rewrite interactiveStates by hand.
Since we want to go for an opt-in (allowlist) approach instead opt-out (blacklist), we should remove the concept of blacklist and restrictTo altogether and perhaps expose a custom option that is a function that should return an array of supported pseudo-classes. This function will get the list of default.
let defaultClasses = [':hover', ':active', ':focus', ':visited', ':focus-visible', ':focus-within'];
if (typeof options.custom === "function") {
defaultClasses = options.custom(defaultClasses);
if (false === Array.isArray(defaultClasses)) {
throw new Error("options.custom: Invalid return value. The function should return an array of strings");
}
}
if you want options.custom can be polymorphic and be either the function above or an Array that will override everything
@giuseppeg I updated API to custom
I need to merge it to master to make another PR
I will add changes to that PR to avoid merging
I also moved to modern JS syntax, but I think we need to merge https://github.com/giuseppeg/postcss-pseudo-classes/pull/46 to fix CI.
But these 2 PRs is all changes which I am suggesting. We can merge them and release.
Merged the other, feel free to rebase.
Rebased and fixed. Merge and release when you will be ready.
Thanks! Will do it tomorrow morning because I am not home