-
-
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 selector-max-specificity
to leverage upstream helper
#7689
Refactor selector-max-specificity
to leverage upstream helper
#7689
Conversation
|
Be bold and say that's what you intended all along :) |
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.
@romainmenke Thanks for the pull request. This is a great improvement! Overall LGTM, but I've left a few comments, so I'd appreciate if you would check them out.
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
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, LGTM 👍🏼
Thank you for the reviews 🙇 |
None
While working on
selector-max-specificity
for the end position fix I noticed that all of the complexity in the rule is for theignoreSelectors
secondary option.Because this option is present it is needed to manually walk the selector and re-implement large sections of
@csstools/selector-specificity
so that ignoring selectors works as expected.I've added an option upstream to customize the specificity calculations.
See : https://github.com/csstools/postcss-plugins/blob/main/packages/selector-specificity/docs/selector-specificity.selectorspecificity.md
Because this is integrated into
@csstools/selector-specificity
we can offload a lot more complexity to that package.A good example was all of the logic around
:nth-child(n of .foo)
.All this logic already existed upstream but couldn't be used before.
A side effect of this change is that this rule is also a bit faster.
Without secondary options.
Main:
This change:
With secondary options.
Main:
This change: