Re: [csswg-drafts] [css-nesting-1] CSSOM for nested media query rules (#7850)

Summarizing the discussion:

1. Appeared to be consensus on "wrap naked properties in a `& {...}` rule".
2. Everyone also wanted consistency between the behavior of properties in nested style rules and in nested conditional rules. That is, `.foo { color: red; & { width: 100px; } width: 200px; }` and `.foo { color: red; @media all { width: 100px; } width: 200px; }` should be consistent.
 1. Most importantly, consistency in cascade behavior (either `width: 100px` wins in both examples above, or `width: 200px` wins in both). (Currently `width: 100px` wins in nested style rules; the `200px` gets pulled up to the front, and the nested rule is considered "after" it.)
 2. Less importantly but not *un*important, consistency in OM behavior.

There were two branches of possible suggestions to address the above (particularly improving the OM consistency):

1. Add a `.style` accessor to conditional rules, but somewhat magical - it just routes to the first child rule if it's a "default &{...} rule" as described above (and creates such a rule if one doesn't currently exist).
2. Change the parsing of style rules so they also wrap their naked properties in &-rules, *if they follow other nested rules*. (Properties preceding any other rules stay as they are, getting handled by `.style` rather than a nested rule.)

We ran out of time during the meeting to wrap up this discussion, but there was mild opposition to both of these ideas. 

For (1), the thought was that this felt a little too magical, especially with the implicit rule creation+insertion on the first write to .style. 

For (2), there was a minor perf concern - this would mean doing more selector matching in this case. There's also a concern about the interpretation wrt shorthands; shorthands + longhands are coalesced in particular ways when they're in the same style block, but would produce a slightly different behavior if spread across multiple style blocks.

I propose in our next take-up of this issue that we resolve to just do the "wrap naked properties in a `&{...}` rule" part.

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7850#issuecomment-1404011020 using your GitHub account


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

Received on Wednesday, 25 January 2023 17:55:17 UTC