W3C home > Mailing lists > Public > public-css-archive@w3.org > November 2020

[csswg-drafts] [css-nesting] Allow more direct nesting delimiters (#5746)

From: Jonathan Neal via GitHub <sysbot+gh@w3.org>
Date: Wed, 25 Nov 2020 19:29:01 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-751068788-1606332539-sysbot+gh@w3.org>
jonathantneal has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-nesting] Allow more direct nesting delimiters ==
[CSS Nesting](https://drafts.csswg.org/css-nesting) avoids unbounded lookahead to tell whether a given bit of text is a declaration or the start of a style rule by requiring a single token of lookahead in its parsing. These tokens are either the [`<delim-token>`](https://drafts.csswg.org/css-syntax/#typedef-delim-token) or [`<at-keyword-token>`](https://drafts.csswg.org/css-syntax/#typedef-at-keyword-token). More specifically, the `<delim-token>` must have a value of `&`, and the `<at-keyword-token>` must have a value of `nest`.

May we expand the allowable value of the `<delim-token>` to include non-`&` values for descendant nesting?

Before this proposed change, here is a sample of allowable CSS (_from [CSS Nesting: Example 4](https://drafts.csswg.org/css-nesting/#example-ea9c9742)_):

```css
.foo {
  color: blue;
  & > .bar { color: red; }
}

.foo, .bar {
  color: blue;
  & + .baz, &.qux { color: red; }
}

.foo {
  color: blue;
  & .bar, & .baz, & .qux { color: red; }
}
```

After this proposed change, here is an updated sample of allowable CSS:

```css
.foo {
  color: blue;
  > .bar { color: red; }
}

.foo, .bar {
  color: blue;
  + .baz, &.qux { color: red; }
}

.foo {
  color: blue;
  .bar, .baz, .qux { color: red; }
}
```

This would further align syntactically-allowable CSS nesting with existing user-land CSS nesting (e.g. Stylis, Sass).

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


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Wednesday, 25 November 2020 19:29:06 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:42:22 UTC