Skip to content

Make interleaved declaration semantics CSS-compatible #3846

@nex3

Description

@nex3

w3c/csswg-drafts#8738 changes the behavior of declarations interleaved with nested rules away from behavior that matches Sass's historic behavior (hoisting all properties to the original nested rule), and instead treats those behaviors as logically appearing after the nested rule. For example, the source:

a {
  color: red;
  @media screen {color: blue}
  color: green;
}

currently compiles to:

a {
  color: red;
  color: green;
}

@media screen {
  a {
    color: blue;
  }
}

but the CSS semantics are now equivalent to:

a {
  color: red;
}

@media screen {
  a {
    color: blue;
  }
}

a {
  color: green;
}

...which is meaningfully different. Reportedly, Chrome will be implementing the new semantics soon.

Although our approach to full compatibility with plain CSS nesting semantics is generally fairly cautious due to Sass's strong existing semantic grounding (see #3030), in this case the set of styles that will need to change is fairly narrow and a workaround is easy (wrapping the properties in & { ... }), so it's worth changing this behavior eagerly.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions