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

feat: build stylesheet with supported extended selectors #4442

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

seia-soto
Copy link
Member

We want to support :has as a native CSS pseudo class. This PR allows users to produce a stylesheet with cosmetic filters which only includes supported pseudo classes regarded as extended. However, we have multiple aspects to determine if this approach really the most effective way to support :has.

  1. Is generalization really required?
    In this PR, I aim to generalize and extend the problem to all possible CSS pseudo classes. However, we may not need to target other pseudo classes rather than :has. :has solves a lot of problems in CSS selector by allowing users to select parent element. Also, I don't expect new pseudo class will be released in short. Therefore, we may not generalise the whole logic just to support :has.

  2. Do we want to determine if a full selector is supported or not in runtime?
    I think it depends on the cost of tokenization. We can still cache the results in the filter or cosmetic budget, but it will result in pretty much of computation and memory pressure. Instead, we can do the determination in the parse time as we're already checking if a selector is extended or not. In this case with an assumption that we only want to take care about :has, one consideration is to add a new bit field in COSMETICS_MASK.

  3. How much safety do we want to add?
    When building a stylesheet, the safety is ensured at block level. If we want to be safe about specific selector, we need to put them in separate blocks. Depending on the degree, we need to decide how many blocks we want to add.


If I wrap up, there are three things to decide:

  • Target only :has or not
  • Decision in parse time or runtime (hotpath in matching)
  • How to check if a selector is only consisted with specific pseudo classes
  • How many blocks we want to add for the fail-safe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: New Feature 🚀 Increment minor version when merged WIP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant