[csswg-drafts] [css-nesting] Define how relative selectors serialize. (#8970)

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

== [css-nesting] Define how relative selectors serialize. ==
https://drafts.csswg.org/css-nesting/#syntax says that you're supposed to parse relative selectors while nesting.

However it doesn't say anything about how to serialize them.

```html
<!doctype html>
<style>
  .foo {
    +bar {
      color: green;
    }
  }
</style>
<script>
  console.log(document.styleSheets[0].cssRules[0].cssRules[0].cssText);
</script>
```

Blink and WebKit serialize the selector as written (so, `+ bar`).

That's ok, I suppose, but I tend to think it'd be more useful if it serialized to the expanded form (`& + bar`). That means that `.cssText`, `.selectorText`, etc are always valid, independently of whether the rule is a nested style rule or not. So you can always do `oneRule.selectorText = anotherRule.selectorText`.

Thoughts?

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


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

Received on Thursday, 15 June 2023 16:34:33 UTC