[csswg-drafts] [css-nesting] Inserting new sub-rules with .style (#7933)

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

== [css-nesting] Inserting new sub-rules with .style ==
During test writing, this came to mind:

```js

<style>
  .a {
    color: red;
    &.c { color: hotpink; }
  }
</style>
<script>
document.styleSheets[0].rules[0].style = 'color: navy; &.b{color: green;}';
</script>
```

What should happen?

1. The change is silently ignored.
2. “color: red” is changed to “color: navy” and no other changes take place.
3. The same, but an additional rule “&.b { color: green; }” is added, above &.c.
4. The same, but it's instead added after &.c.
5. The same, but &.c is removed.

I'd say the sane thing to do is 2 since we parse a list of declarations (and already ignore `@media` etc. when setting .style), but this needs to be explicit in the spec, I think. 

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


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

Received on Friday, 21 October 2022 11:22:09 UTC