Re: [csswg-drafts] [css-syntax][css-nesting] Design of `@nest` rule (#10234)

Current draft:

(tl;dr We support options 2 or 3 from the OP, with a slight preference for 2.)

WebKit strongly opposes introducing an `@nest` rule for this purpose. We don't think expanding the syntax space of CSS for the convenience of CSSOM representation is an acceptable cost to authors, and prefer a solution that represents interleaved style declarations in the CSSOM in a way that does not have an externality on CSS syntax.

Our suggestion is to:
- Introduce a `CSSNestedDeclarations` object inheriting from `CSSRule` and having a `.style` accessor, and use that to represent all the declaration lists in a `CSSStyleRule`. It serializes as a raw declaration list.
- Represent the first declaration list both as `.style` on the `CSSStyleRule` directly (as currently) and as `.style` on the first `CSSNestedDeclarations` object inside `.cssRules`, making `.cssRules` a comprehensive and consistent representation of all the contents of the style rule, and `.style` a convenient shorthand for accessing that first `CSSStyleDeclarations` object.
- Extend `.insertRule()` to parse declarations or add `.insertDeclarations()`, which appends those declarations to the immediately previous declarations list, if any, and otherwise creates a new `CSSNestedDeclarations` object to append to and inserts that.

We believe this approach has a lower cost to authors than introducing a new at-rule into the general syntax that has no true purpose other than CSSOM representation of interleaved styles.

We would also be OK with alternative solutions that don't introduce an at-rule, such as inserting `CSSStyleDeclaration` objects directly into `.cssRules`, or including only interleaved declaration lists in `.cssRules`.

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


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

Received on Thursday, 16 May 2024 23:40:49 UTC