Re: [csswg-drafts] [css-nesting] Require `div&`, disallow `&div`, for Sass compat (#8662)

The CSS Working Group just discussed ``[css-nesting] Require `div&`, disallow `&div`, for Sass compat``, and agreed to the following:

* `RESOLVED: type selector remains required first; &div is invalid`

<details><summary>The full IRC log of that discussion</summary>
&lt;fantasai> TabAtkins: In previous version of Nesting, we relaxed restriction to starting with a tag selector in order to allow &amp; at the front<br>
&lt;fantasai> ... which was required for previous parsing solutions<br>
&lt;fantasai> TabAtkins: SASS uses &amp; as a textual substitution, so if you write &amp;div, you're asking SASS to append the letters "div", so if your parent selector was ".foo" you get ".foodiv"<br>
&lt;fantasai> ... having this mismatch would be an annoying upgrade story for them, because this sort of concatenation is very heavily used<br>
&lt;fantasai> ... due to object-oriented class naming patterns<br>
&lt;fantasai> ... On the other hand, putting additional type selectors on the compound selector is exceedingly rare<br>
&lt;fantasai> ... she's heard the request only a few times<br>
&lt;fantasai> ... So this is very low priority for them<br>
&lt;fantasai> ... upshot of all this, is I suggest we remove the relaxed restriction that allows type selectors to not be at the front<br>
&lt;fantasai> ... restoring us to previous restriction, which requires the tag selector in front<br>
&lt;fantasai> ... then you can write div&amp; but not &amp;div<br>
&lt;fantasai> ... which protects that syntax space for SASS and related languages<br>
&lt;fantasai> TabAtkins: This also helps with some degree of migration<br>
&lt;fantasai> ... if they know it's an error, they can autocorrect to the right form<br>
&lt;fantasai> TabAtkins: I was initially uncertain of specifying this, if there is already usage of &amp;div in Chrome or Safari<br>
&lt;fantasai> ... but apparently Chrome's implementation never relaxed that restriction so &amp;div has been invalid this whole time<br>
&lt;fantasai> TabAtkins: so at least for Chrome, this isn't an issue, so making this invalid again would be fine<br>
&lt;fantasai> ... unclear about Safari I couldn't test<br>
&lt;fantasai> TabAtkins: So I propose to revert the syntax restrictions<br>
&lt;fantasai> ??: [missed]<br>
&lt;fantasai> ??: We don't have the same behavior as Chrome, so it would be a breaking change for us<br>
&lt;fantasai> astearns: Given that there is likely not that much content targetting Safari's current implementation, would you be ok with this change?<br>
&lt;fantasai> ??: Pretty sure there are zero websites targetting it, so won't break the Web<br>
&lt;oriol> q+<br>
&lt;fantasai> TabAtkins: Then I ask for a resolution<br>
&lt;dbaron> s/??/matthieu/<br>
&lt;fantasai> s/??/mattieu/<br>
&lt;fantasai> s/??/mattieu/<br>
&lt;astearns> ack oriol<br>
&lt;emilio> +1 to keep that restriction, fwiw on Firefox's impl I never implemented it either<br>
&lt;oriol> Lety me reconnect<br>
&lt;fantasai> jensimmons: Curious to know what miriam thinks about this issue<br>
&lt;fantasai> miriam: I think this is a good idea, for the reasons Tab listed<br>
&lt;fantasai> ... I am not on the internals of everything that Natalie is conerned about here, but was part of the conversation with Tab and agree this is the direction to go to minorly limit a problem<br>
&lt;astearns> ack oriol<br>
&lt;fantasai> oriol: I'm opposed to the restriction, but not clear to me how exactly it's helping. In SASS the behavior is something else, and ppl are using that behavior, if they switch to Nesting they will have to adapt somehow anyway<br>
&lt;dbaron> s/mattieu/matthieu/<br>
&lt;fantasai> ... I'm not sure whether it's invalid or it means something different, if it is that relevant to people<br>
&lt;dbaron> s/mattieu/matthieu/<br>
&lt;fantasai> TabAtkins: As much as possible, SASS tries not to interpret valid CSS differently as how browsers would interpret it<br>
&lt;fantasai> ... It is helpful if we put it as invalid syntax, so it is definitely not something that would mean something in the browser<br>
&lt;emilio> q+<br>
&lt;fantasai> ... It's not strictly necessary, because they'll have compat pain anyway, but a long-term goal here, is that as long as author is not using SASS-specific features, they want to emit native CSS in the future<br>
&lt;astearns> ack emilio<br>
&lt;fantasai> ... being certain about using CSS-compatible syntax or invalid syntax that is SASS-interpreted is a goal<br>
&lt;fantasai> emilio: If we ever expose the final selector somehow, it would be weird if this couldn't be serialized in anyway<br>
&lt;fantasai> ... so I support not allowing &amp;div<br>
&lt;fantasai> emilio: In particular, if devtools wanted to show the final selector that this element matched, you want to see something useful<br>
&lt;fantasai> ... if you write &amp;div, you can't just expand it<br>
&lt;fantasai> emilio: so I would prefer to avoid this special case<br>
&lt;fantasai> astearns: Other comments or conerns?<br>
&lt;fantasai> s/conerns/concerns/<br>
&lt;fantasai> TabAtkins: Proposed to remove relaxation of type selector rules, keep current rule that type selector must be first in a compound selector<br>
&lt;fantasai> astearns: objections?<br>
&lt;fantasai> RESOLVED: type selector remains required first; &amp;div is invalid<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8662#issuecomment-1514977935 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 19 April 2023 15:55:28 UTC