Re: [csswg-drafts] [css-cascade] [css-nesting] Figure out whether we're fine with "shifting up" bare declarations after rules (#8738)

The CSS Working Group just discussed `[css-cascade] [css-nesting] Figure out whether we're fine with "shifting up" bare declarations after rules`.

<details><summary>The full IRC log of that discussion</summary>
&lt;bramus> … in terms of options, we can say that when you are interleaving, you have to make additional ampersand rules to have them maintain their position<br>
&lt;fremy> q+<br>
&lt;bramus> … seems stragithforward but are concerned that we should fix the cascade bc it is confusing<br>
&lt;miriam> q-<br>
&lt;bramus> TabAtkins: main arg for no change is that this behavior is the same as what preprocessors do since they supported it<br>
&lt;bramus> … it has not been a problem for any of them as far as we can tell<br>
&lt;bramus> … for sass we have a maintainer confirming that<br>
&lt;bramus> … so we dont need to worry about it I think<br>
&lt;bramus> … it is not an issue in practice, so we should not come up with complicated solution<br>
&lt;bramus> … MQs and non-style rules have a different behavior when nested than style rules are<br>
&lt;bramus> … style rules put all their props in the style as ??? if it were up front<br>
&lt;myles> q?<br>
&lt;bramus> s/???/<br>
&lt;bramus> … and mqs in similar put all their ?? in nested style rules<br>
&lt;Rossen_> ack TabAtkins<br>
&lt;bramus> … we could run into the issue that knowing when nesting has begun depends on non; it is not ituitive what to define well when we have started nested<br>
&lt;bramus> … a rule that is unknown or mistyped can change that interpretation<br>
&lt;bramus> … in an unpredictable way<br>
&lt;bramus> …. to keep consistent behavior lets avoid that problem entirely, and data from preprocessors has shown it is not a problem<br>
&lt;bramus> fremy: the last argument seems valid<br>
&lt;Rossen_> ack fremy<br>
&lt;bramus> … the examples emilio gave is not about nesting selectors but nesting an at-media rule, which I can do<br>
&lt;bramus> … i feel example is convincing enough<br>
&lt;bramus> … is implementation of sass/less supporting this use case?<br>
&lt;bramus> … if they dont, then we are making things quite ???<br>
&lt;bramus> TabAtkins: yes, i believe they do<br>
&lt;bramus> … throw it into a sass playground and it will output the euiqvalent compliled code with media shifted out<br>
&lt;bramus> … the two decls will be grouped together<br>
&lt;Rossen_> q?<br>
&lt;bramus> s/grouped/combined<br>
&lt;bramus> fremy: in this case I dont feel strongly enough that we should<br>
&lt;bramus> emilio: so fixing interleaved decls inside a grouping rule by wrapping in &amp;-rule is easy<br>
&lt;bramus> … fixing style rules by adding nested style rules is not too hard but … I guess we could fix it<br>
&lt;bramus> … dont feel too strongly either way<br>
&lt;TabAtkins> yup, today emilio's examples compiles to "the div with both properties, followed by the @media holding a div holding the conditional props"<br>
&lt;ntim_> q+<br>
&lt;bramus> Rossen_: so then the proposed resolution is to close no change<br>
&lt;ntim_> q-<br>
&lt;bramus> fremy: did anybody look into ???’s comment?<br>
&lt;bramus> Rossen_: we did,<br>
&lt;myles> q?<br>
&lt;fremy> s/???/Lea Verou/<br>
&lt;bramus> jensimmons: we do not like the proposed resolution. it does not make sense for authors right now. they expect for the later styles to apply<br>
&lt;bramus> … i agree that a non-complicated thing is a goal, bu tshould not be what we have now<br>
&lt;ntim_> +1<br>
&lt;bramus> … sass is a guiding principle, but we should follow how CSS has always worked: source order<br>
&lt;bramus> … ntim has a proposal<br>
&lt;bramus> ntim_: emilio wrote it in the issue : wrapping in &amp;<br>
&lt;miriam> Here's the example in a Sass playground, for reference (sorry it's a long url): https://sass-lang.com/playground/#MTFkaXYlMjAlN0IlMEElMjAlMjBjb2xvciUzQSUyMGdyZWVuJTNCJTBBJTIwJTIwJTQwbWVkaWElMjAod2lkdGglMjAlM0UlMjAwKSUyMCU3QiUwQSUyMCUyMCUyMCUyMGNvbG9yJTNBJTIwcmVkJTNCJTBBJTIwJTIwJTIwJTIwYmFja2dyb3VuZCUzQSUyMHJlZCUzQiUwQSUyMCUyMCU3RCUwQSUyMCUyMGJhY2tncm91bmQlM0ElMjBncmVlbiUzQiUwQSU3RA==<br>
&lt;bramus> astearns: just for my clarification: that solution will allow later rule to override the earlier ones?<br>
&lt;bramus> [multiple]: yes<br>
&lt;bramus> plinss: i presume for wrapping ??? in another declaration block it becomes another rule in the OM?<br>
&lt;bramus> TabAtkins: yes<br>
&lt;bramus> plinss: is the &amp; still required these days?<br>
&lt;bramus> TabAtkins: yes, you need a selector<br>
&lt;bramus> … in terms of raw css syntax parsing, omitting ths eelector will give you a rule with empty prelude and that will fail to parse as valid style rule<br>
&lt;oriol> q+<br>
&lt;bramus> TabAtkins: further issue as explained in thread. anything we do that distinguished behavior on before/after nested rule means we have to define the switch for 'we are past a nested rule'<br>
&lt;emilio> q+<br>
&lt;bramus> … cant be ??? to cause the syntax trigger<br>
&lt;bramus> … we dont need that concept if we dont do this<br>
&lt;bramus> … it will potentially change the cascade<br>
&lt;bramus> emilio: why would you have problem to just use valid nested rule as trigger?<br>
&lt;bramus> TabAtkins: bc a new rule that does not exist in older browser that understands nesting will throw away tgha tnew rule and conclude tha tnesting hasnt started yet<br>
&lt;bramus> emilio: and the declarations will ?? and that seems fine<br>
&lt;bramus> TabAtkins: and the OM changes<br>
&lt;bramus> emilio: ????<br>
&lt;bramus> emilio: like the OM changes, but it also changes when you itnroduce new rules.<br>
&lt;bramus> … you end up with different ??? list<br>
&lt;Rossen_> q?<br>
&lt;bramus> fantasai: if we have style rule with interleaved rules and declarations. lets say 3 decls at top, at-rule, and 2 decl at bottom<br>
&lt;SebastianZ> s/???/length/<br>
&lt;bramus> … old browser will have 5 decls appear in .style of that stylerule<br>
&lt;bramus> … if we wrap it in ??? then in a new browser you would get first 3 decls in ./style. then at-media in .cssRules followed by - followed in it -  a new style rule with last 2 decls<br>
&lt;bramus> TabAtkins: not, but that is closely related.<br>
&lt;dbaron> ScribeNick: dbaron<br>
&lt;SebastianZ> s/???/an :is() rule/<br>
&lt;Rossen_> ack oriol<br>
&lt;TabAtkins> specifically, `::before { &amp; {color: red;}}` does *not* apply red to ::before in today's spec<br>
&lt;dbaron> oriol: about wrapping decls in an &amp;:  with two elements, the &amp; can't represent 2 elements.  If you have a declaration, garbage, and a declaration -- if later a new feature parses the garbage as a nested rule, then the following declaration would be grabbed and not work.<br>
&lt;TabAtkins> and causing implicit wrapping would trigger that problem as well<br>
&lt;matthieudubet> (is oriol mic working ? the sounds seems far away)<br>
&lt;dbaron> oriol: while I agree the current behavior is not great, and would be a good oargument for chosoing option 4, I'm leaning more towards what tab is saying -- keeping current behavior<br>
&lt;emilio> ack emilio<br>
&lt;Rossen_> q?<br>
&lt;matthieudubet> (yes that was better at the end with the new mic)<br>
&lt;dbaron> TabAtkins: I forgot about that -- I agree that kills it harder.  You can't nest if your parent rule has pseudo-elements.  That's the behavior of :is().  If you tried to do this and parent selector applied styles to pseudo-elements, the implicit wrapping would just drop these declarations on the floor.  That's broken at a fundamental model level right now.<br>
&lt;dbaron> plinss: that goes away if we get rid of the :is() behavior, right?<br>
&lt;dbaron> TabAtkins: yes<br>
&lt;ntim_> q+<br>
&lt;dbaron> TabAtkins: my proposed resolution is still to close with no change; I think current spec is right.<br>
&lt;dbaron> TabAtkins: but we should see if objection from Apple is still standing<br>
&lt;Rossen_> ack ntim_<br>
&lt;dbaron> ntim_: I wonderif we can translate to a ? rule without using &amp;, just using the selector text.<br>
&lt;ntim_> div {   color: green; }   @media (width > 0) {     div {       color: red;       background: red;     }   }   div {     background: green   }<br>
&lt;dbaron> TabAtkins: no, b/c that's a relative selector<br>
&lt;dbaron> TabAtkins: those nested rules are "div div"; it's still relative to the parent rule<br>
&lt;dbaron> hober: siblings, not nested<br>
&lt;dbaron> myles: there's 3 sibling rules in that example<br>
&lt;dbaron> TabAtkins: that would mean treating nesting as a preprocessor directive that rewrites into a different rule structure<br>
&lt;dbaron> TabAtkins: we haven't been pursuing that approach since very early on in nesting.  I'd like to reject trying to rewrite style things.  That makes many things more complicated, like for how @media nesting works in rules.  But the more we diverge the OM and the model underneath from the syntax authors write, the worse it is.<br>
&lt;dbaron> fantasai: I think I'm not comfortable resolving on no change -- it doesn't sound like we have consensus -- but we don't have a clear counterproposal worked out.  I think TabAtkins brought up many useful concerns with emilio's path.  We should take some time outside the meeting to review minutes and try to think through the psosibilities.  Might be down to these 2, but maybe something else.   And see if we can address relevant concerns, or at<br>
&lt;dbaron> ... least have a better understanding of what they are<br>
&lt;dbaron> [mic out of battery]<br>
&lt;jensimmons> +1 to what Elika just said<br>
&lt;dbaron> TabAtkins: If you think it's valuable to more exploration, you're welcome to.  I don' t think it's going to work, but you're welcome to.<br>
&lt;dbaron> fantasai: Sounds like there's an aciton item for people with concerns about current proposal to come up with a counter proposal.<br>
&lt;dbaron> Rossen_: No rule that we can't reopen issues.<br>
&lt;dbaron> fantasai: I object to resolving when this many people don't like the direction.<br>
&lt;dbaron> TabAtkins: As long as it's not a drastic change (like turning it into a rewriting rule), unlikely there will be compat concerns if it changes relatively soon, given that this is a rare code pattern.  But not indefinitiely, and limitations on how far that reaches.<br>
&lt;dbaron> Rossen_: So let's move on to the next issue.  And once Apple or anyone else has a better proposal, bring it back.<br>
&lt;astearns> fwiw I have already seen authoring advice against mixing rules and declarations this way, so if people follow that advice it lessens the compat concerns<br>
</details>


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


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

Received on Wednesday, 19 July 2023 22:16:03 UTC