Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make interleaved declaration semantics CSS-compatible #3846

Open
1 of 7 tasks
nex3 opened this issue Apr 22, 2024 · 1 comment
Open
1 of 7 tasks

Make interleaved declaration semantics CSS-compatible #3846

nex3 opened this issue Apr 22, 2024 · 1 comment
Labels
CSS compatibility Support the CSS spec enhancement New feature or request

Comments

@nex3
Copy link
Contributor

nex3 commented Apr 22, 2024


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.

@nex3 nex3 added enhancement New feature or request CSS compatibility Support the CSS spec labels Apr 22, 2024
nex3 added a commit that referenced this issue Apr 22, 2024
nex3 added a commit that referenced this issue Apr 22, 2024
nex3 added a commit that referenced this issue Apr 22, 2024
nex3 added a commit that referenced this issue Apr 22, 2024
nex3 added a commit that referenced this issue Apr 24, 2024
@nex3
Copy link
Contributor Author

nex3 commented Apr 30, 2024

The proposal has landed. Since it does involve a deprecation, I'm going to give it a month for public comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CSS compatibility Support the CSS spec enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant