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

ignore :is pseudoclass as parentheses can contain unhandled spaces and further pseudoclasses #51

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

eoghanmurray
Copy link

  • when :is was escaped, the space within the brackets was not escaped and we got a unusable class of a\:is\(.\:hover, .current), which also has an unescaped closing bracket
  • IMO without allCombinations it's reasonable to expect the :is to be maintained as-is, so that explicit .\:hover classes can be programmatically added without having to add classes for each of the :is rules in the stylesheet, which is likely to be non-trivial given how this pseudoclass is used in the wild.

I've solved in this PR by blacklisting :is, but possibly there is a better solution out there which IMO would need to replicate some of the effect of allCombinations even in the absence of that option.

Example ideal solution, not implemented in this PR:

    a:is(:hover, .current, .\:hover),
    a.\:is\(\:hover\,\ \.current\) {
      color: firebrick;
    }

Above demonstrates recursive addition of new class within the 'sub selector' of the :is parenthesis, as well as proper escaping of a full :is statement (which I can't imagine anyone ever using)

 - without `allCombinations`, the space within the brackets is not escaped, so currently we get a unusable class of `a\:is\(.\:hover, .current)`, which also has an unescaped closing bracket
 - even without `allCombinations` it's reasonable to expect the `:is` to be maintained as-is, so that explicit `.\:hover` classes can be programmatically added without having to add classes for each of the `:is` rules in the stylesheet, which can be non-trivial
…solution:

a:is(:hover, .\:hover, .current),
a.\:is\(\:hover\,\ \.current\) {
  color: firebrick;
}
@eoghanmurray
Copy link
Author

This came about due to a test case from the following PR in another repository: rrweb-io/rrweb#1535

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant