-
Notifications
You must be signed in to change notification settings - Fork 693
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[css-nesting-1] Invalid nested selectors #7503
Comments
see : #7433
|
Changing the title to broaden the topic with the following cases: type { &type {} }
.subclass { &type {} } The first can only be invalid, even when expanded using The latter would be valid only if it is expanded using
This currently appear in a note. Maybe it should be normative? |
Those are only invalid when treating the selectors as strings but that is something only preprocessors do. I would assume p:is(p) {
color: green;
}
is(p):is(p) {
color: green;
}
I agree, because in practice these are tightly coupled :
|
Yeah, Romain, you are right:
EDIT: nope, it seems not, according the note related to the BEM pattern, which should also be normative, imo, therefore I think the above definition can be clarified. |
Also somewhat related to : #7972
|
For the question in the OP, this is a dupe of #2880.
|
I did not asked how to handle invalid nested style rules but if a selector of a nested style rule that would be invalid when desugared, should be invalid. I do not know how selectors in Example 10 seems to be defining that selectors that would be invalid (like For example, Anyway, I will wait for the next edits of the spec. |
Following latest spec edits and after carefully re-reading all related issues, I have a better understanding of how a nest-containing selector is desugared. Basically, First, I think an example showing that there is no difference between Second, it is still not clear to me if this resolution with :root { ::before&, .valid {} } /* `::before:is(:root)` is invalid */
span { ::before + &, .valid {} } /* `::before + :is(span)` is invalid */
I intentionally used But more importantly and put more explicitly, I would like to know if desugaring |
No, the desugaring with
As currently written,
I'm not sure why your comment says " |
Right, sorry. Thanks for considering allowing it.
I may be misunderstanding 3.6.5. Internal Structure:
So the explicit answer to my question is: if the prelude of a nested style rule is invalid (after desugaring |
Ah yes, you're right, But yeah, |
Please note that with
However the examples in the spec seems to remember its position. This is another reason why I commented:
|
If |
Note that "desugaring" is purely informative. Nothing shown in the examples actually occurs in impls; we're just showing equivalent selectors so the behavior can be understood in terms of existing features.
These examples are all showing cases where the compound selector contains a type selector. When writing a selector without an &, as we're showing here, type selectors are required to go first, so the reordering is required. More generally, rearranging components of a compound selector is a no-op. On the other hand, |
Ok, I got it, thanks. Fortunately, I think authors will always choose the position of |
I think CSS Nesting or CSS Selector 4 (probably the former) should clarify something like "An invalid complex or compound selector remains invalid when some of its parts are nested":
Currently, in CSS Selector 4:
The text was updated successfully, but these errors were encountered: