feat: build stylesheet with supported extended selectors #4442
+56
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
.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
.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 inCOSMETICS_MASK
.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:
:has
or not