Skip to content

[css-nesting] Inserting new sub-rules with .style #7933

@sesse

Description

@sesse

During test writing, this came to mind:

<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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions