-
Notifications
You must be signed in to change notification settings - Fork 639
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
[css-nesting-1] Allow relative selector syntax in @nest
rules.
#7854
Comments
FWIWI, if we go with option |
@FremyCompany I think we should do this regardless of which option we choose. It's compatible with all of them. We noted it in #7834 (comment) but the discussion was mostly about other aspects. Worth splitting out though, so I'll Agenda+ |
@fantasai It is only compatible with option 1 as currently discussed. All other options drop |
@romainmenke Yeah, so in option 3 you could just write
and in option 4 it would be
or
|
@fantasai This issues was specifically about adding relative selector syntax in This as a way to have all the benefits of relative selector syntax without all the downsides of the other proposals. This also allows us to do this :
|
The CSS Working Group just discussed
The full IRC log of that discussion<emeyer> Topic: Allow relative selector syntax in @nest rules<emeyer> GitHub: https://github.com//issues/7854 <emeyer> fantasai: We had talked about adopting relative selectors as a way of writing nested selectors <emeyer> …Thus is you have a combinator, you could just write it without prefixing with an ampersand (&) <emeyer> …I believe all proposed syntaxes can accept having relative selectors <emeyer> …I propose we allow that for all of them <emeyer> …In option 1, you can only put a relative after @nest, but you wouldn’t need an & <fantasai> s/you can/one proposal is you can/ <lea> +1 for relative selectors, +1 for not requiring @nest (the less @nest the better...) <emeyer> fremy: We can also do this for @scope <emeyer> fantasai: I believe that’s correct <emeyer> miriam: I don’t remember if we clarified that, but I agree it should work <emeyer> fantasai: I’ll break this down <emeyer> …Do we want to allow relative selectors for nesting and @scope? <emeyer> Rossen: Feedback or objections? <flackr> q+ <emeyer> flackr: It’s a bit odd that we support all selectors except descendant because of the parsing ambiguousness <Rossen_> ack flackr <emeyer> Rossen: Still not hearing objections, so will call this resolved <miriam> scope spec says :scope is assumed at the start of selectors, which is similar to allowing this (but not entirely explicit) <argyle> i like the relative selector feature as nesting 2 <emeyer> RESOLVED: allow relative selectors for both nesting and @scope <fantasai> Note: @scope already has this <fremy> proposal is we allow `@nest > x` == `@nest & > x` <emeyer> fantasai: The next piece is that for option 1 syntax, where you have to start with an ampersand, do we require it @nest? <emeyer> lea: The less @nest, the better <emeyer> TabAtkins: I don’t think it’s useful to discuss option 1 syntax since we don’t know if we’re going to use it <astearns> q+ <emeyer> fantasai: Whether descendant selectors are allow ing nesting will depend on a following discussion <emeyer> astearns: Because of the weirdness about descendant selectors, should we define an actual optional syntax for descendant selectors in nest and @scope situations? <fantasai> s/allow ing/allowed to be written as relative selectors in/ <Rossen_> ack astearns <emeyer> TabAtkins: I think we should but that should be a different discussion <emeyer> Rossen: Please open an issue on that if we don’t already have one, Alan? <emeyer> …Anything else on this topic? <emeyer> (no) <Rossen_> https://github.com/w3c/csswg-drafts/blob/main/css-nesting-1/proposals.md <TabAtkins> /me I propose in the next topic we have a quick refresher on the options (happy to do it, or elika or lea), then have a shortish comment period, then straw poll. <fantasai> -> https://github.com/w3c/csswg-drafts/blob/main/css-nesting-1/proposals.md <emeyer> lea: If you followed all this and have an opinion but haven’t recorded a vote, please do so! |
Nesting spec now reflects this; retagging to Cascade 6 to track the remaining edits to |
@tabatkins This issue was specifically about the now removed proposal 1. It was very specifically about : .foo {
@nest > .bar {
/* & > .bar */
/* .foo > .bar */
}
} Maybe it will be less confusing to open a new issue? |
No, we chose to reinterpret this as a general referendum on relative selectors in places where we allow nesting. Check the minutes of the discussion. |
The details of how we spec this in |
This is an alternative proposal to : #7834
It only focusses on a single part of the issues brought up there:
Only nested selectors with a single
&
and if the&
is located at the start of the selector could currently match elements outside of a nesting context. (correct me if I am wrong)Can work in different contexts :
&.foo
& .foo
& + .foo
& .foo + .bar
I am unsure about these :
.foo&
.foo &
These will likely not match anything :
& + &
& + .bar ~ &
What makes sense to copy-paste is already a subset of all possible kinds of nesting selectors. So maybe this can be a "power feature" unlocked by using
@nest
in the current nesting syntax?@nest
already unlocks more features in todays nesting syntax.Also valid:
The text was updated successfully, but these errors were encountered: