[csswg-drafts] [css-nesting-1] Why is CSSNestingRule separate? (#7831)

sesse has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-nesting-1] Why is CSSNestingRule separate? ==
The CSSOM part of css-nesting-1 extends CSSRule to support children:

https://csswg.sesse.net/css-nesting-1/#cssom-style

However, then it goes ahead and defines a separate interface, _entirely unrelated to CSSRule_, for nest:

https://csswg.sesse.net/css-nesting-1/#cssom-nesting

I don't understand why these need to be separate. From what I can see, they are identical except for the name. (Also, CSSRuleList does not support containing CSSNestingRule? Wouldn't it need to?) Could we maybe unify them? A proposal would be something like:

* CSSRule is modified as per the current spec.
* CSSNestingRule is removed.
* Direct-nested rules are to be treated as a convenient shorthand for @nest rules.
* When serializing a rule with a nest-containing selector, “@nest ” is added at the start iff not all selectors are nest-prefixed.

In the same vein, there is something that appears to be slightly underspecified: The algorithm for CSSNestingRule's selectorText setter only specifies “if the algorithm returns a non-null value”, but it doesn't explicitly write anywhere that all selectors need to be nest-containing. This makes it potentially possible to write a non-nest-containing nested rule using CSSOM.

@emilio 

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7831 using your GitHub account


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

Received on Wednesday, 5 October 2022 12:16:12 UTC