-
Notifications
You must be signed in to change notification settings - Fork 62
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: support selector intersection #2827
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- combine resolved selector data into a common type that can later be used to retrieve intersection resolve of multiple selectors
2cf5cca
to
b5e71b0
Compare
d9f3950
to
e9fbf22
Compare
- selectorAstResolveMap stores inferred selectors - InferredSelector API for all pseudo-states
- add `nth-child/nth-last-child` to list of pseudo-classes with nested selectors
- flatten `@st-scope` at the end of the transformation - pass nesting inferred selector between rules - fix lsp completions to differ selector inferred context and nesting
…t type - native element already set the inference - just added tests
- tech-debt: with the flag on the transformation of inline custom selector move
- remove extra exp flag arg from ScopeContext - comment about InferredSelector assumptions - add test to check that :not() does nothing yet
tomrav
approved these changes
Mar 14, 2023
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.
Great job, this definitely opens the door for some really cool features down the line, please address requested fixes.
- use "selectorNode" or "ruleOrAtRule" instead of "rule" to describe potential rule or atrule - remove commented imports - remove self referencing module import - changed internal transformer name from "selectorContext" to "inferredNestSelector" - cleaned transformer.createSelectorContext args - remove temp "setCurrentInferredSelectorNode" - unified "duplicateSelectors" pushes - add explanation for SelectorMultiplier.duplicateSelectors
inferred selector for nesting is inferred to the ast node (&), in any other case, fallback to infer the stylesheet root
- fix parent selector collection order - clone selectors to avoid attaching inference to the wrong selector
- prefer to not delete fields from JS objects
- support same stats from the same meta - support identical global states
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds the inference for multiple selector types behinds a new experimental flag that enables support for transformation, validation and completion of cases that combine multiple selectors like:
@st-scope
,@custom-selector
,:is()
,:where()
,:nth-x(, )
, and future support of nested CSS and multiple extends.In addition the new flag is changing the behavior of combinators and other selector nodes so that they will reset the selector inferred type back to the inferred context.
The flag is meant for testing in v5 and is intended to be the default behavior in the upcoming v6
Tasks
experimentalSelectorInference
config flag to activate new behavior (supported fromstylable.config
)Changes in selector type inference with flag
:is()/:where()/:nth-x()
with optional preceding selector type (:has()/:not()
don't narrow the inference)nth-child/nth-last-child
to list of pseudo-classes that support nested selectors (with An+B of S)@st-scope
with multiple selectors@custom-selector
(":--custom") with multiple selectorscombinenot possible because selectors need to be able to change the selector subject,@custom-selector
multiple selectors into:is()
:is()
assumes the nested selectors subject is the preceding compound selector.Fix