-
-
Notifications
You must be signed in to change notification settings - Fork 929
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
Refactor *-specificity
tests and documentation to align with standard CSS
#7688
Refactor *-specificity
tests and documentation to align with standard CSS
#7688
Conversation
|
Can you update
so that it uses either |
selector-max-specificity
tests to align with standard CSS*-specificity
tests and documentation to align with standard CSS
…atch-reality--frank-pygmy-marmoset-f3bfe759f6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I like this change. Can you fix the test failures?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, LGTM 👍🏼
Thank you for the reviews, in particular from @Mouvedia 🙇 |
Closes #7495
As explained in the linked issue
:global()
and:local()
are non-standard functional pseudo classes that have these properties::local(a), :local(b)
and not:local(a, b)
)But they were used in tests to verify the
ignoreSelectors
feature.This feature acts like a hole punch. Only the ignored node is skipped when calculating specificity. The child nodes are still part of the equation.
Given that
:global
and:local
have no specificity of their own and do not allow lists, it isn't ideal that we are using these to testignoreSelectors
. All of the complexity forignoreSelectors
is in calculating the specificity of lists of child selectors.This change replaces
:global
and:local
with:is
and:has
because these do support lists of selectors (e.g.:is(a, b)
).It also adds tests with
:host
because:host
does have its own specificity.This gives us meaningful coverage for
ignoreSelectors
in a way that aligns with standard CSS.The goal of this change is to have coverage in a way that makes it easier to change the implementation of this rule.
The goal is not to make breaking changes that are noticeable to end users, only to make sure that we are testing the right things in the right way.
Side note:
Calculating correct specificity for
:global
,:local
or any other selector is purely an upstream concern in@csstools/selector-specificity
. So I think it is fine if we don't have explicit coverage for these (non-standard) selectors.We need coverage for the rule and for
ignoreSelectors
here, but not for the specificity of any individual selector.