Skip to content

[css-nesting-1] Why is CSSNestingRule separate? #7831

Closed
@sesse

Description

@sesse

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions