-
Notifications
You must be signed in to change notification settings - Fork 672
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-selectors] Allow relative selectors everywhere #8010
Comments
A top-level style rule |
I agree, but I think this is also true for But the current trend is clearly in favour of implicit and terse notations.
I hadn't yet thought about Another one is html {
> body {
color: red;
}
}
@supports selector(> :possibly-invalid) {
html {
> :possibly-invalid {
color: green;
}
}
}
html {
@supports selector(> :possibly-invalid) {
> :possibly-invalid {
color: green;
}
}
} These supports checks fails because relative selectors are not allowed there. |
I don't think we should support top-level relative selectors. It's not immediately clear what they're relative to. If you say "the root", then (a) virtually nothing will ever successfully match, so it doesn't seem useful, and (b) the behavior for "implicit descendant combinator" relatives will be different anyway, since they can match the root. Hammering on (a) a little more, unless you're doing some DOM shenanigans, then neither of the sibling combinators will ever match, and the child combinator will only let you match the |
I think that is the best reason not to do this. I mainly wanted to give this some thought because part of the reason to update the nesting specification was to facility copy/paste of selectors. I don't think the updated specification fully succeeded in that goal but that is fine. This issue can be closed unless someone wants to spend more time on this. |
Yeah, given that the sole copy-paste scenario supported here would be from rules nested inside of |
A significant motivation behind changing the nesting syntax was making selectors easier to copy/paste between contexts.
This changed
.foo { & .bar{} }
into.foo { .bar{} }
Both
.foo
and.bar
can be copy/pasted to any other context, or could have been copy/pasted from any other context..foo { > .bar{} }
however can not be copied to the root of the stylesheet.Currently I think it is only allowed in :
@scope
:has()
#7854 (comment)
Can
> .bar{}
be equal to:scope > .bar{}
in all contexts?All the pseudo's that accept selectors will need to be defined :
:is(> .foo)
:host(> .foo)
Maybe
:scope
is not suitable everywhere?The text was updated successfully, but these errors were encountered: