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

mixed_decls False positive when using plain CSS @property {} CSS-variable declaration blocks #2512

Closed
JeanRemiDelteil opened this issue Feb 12, 2025 · 1 comment

Comments

@JeanRemiDelteil
Copy link

JeanRemiDelteil commented Feb 12, 2025

With the following CSS:

:host {
  @property --lib-my-lib-background-color {
    syntax: '<color>';
    inherits: false;
    initial-value: #dddddd;
  }

  background-color: var(--lib-my-lib-background-color);
  font-family: monospace;
}

The compilation output the following warning

WARNING: ▲ [WARNING] Deprecation [plugin angular-sass]

    src/lib/my-lib.component.scss:14:2:
      14 │   --lib-my-lib-background-color: 1px;
         ╵   ^


  Sass's behavior for declarations that appear after nested
  rules will be changing to match the behavior specified by CSS in an upcoming
  version. To keep the existing behavior, move the declaration above the nested
  rule. To opt into the new behavior, wrap the declaration in `& {}`.
  
  More info: https://sass-lang.com/d/mixed-decls

However, the @Property {} block is native CSS and should not trigger this warning.
It's not a nested rule.

SASS: v1.77.6

@nex3
Copy link
Contributor

nex3 commented Feb 13, 2025

Look at the output of your example:

:host {
  background-color: var(--lib-my-lib-background-color);
  font-family: monospace;
}
@property --lib-my-lib-background-color {
  :host {
    syntax: "<color>";
    inherits: false;
    initial-value: #dddddd;
  }
}

First of all, this isn't producing valid CSS in the first place. Because you're nesting @property within :host, Sass bubbles it up to the top-level and puts :host inside, which isn't legal.

Second, note that the relative order of the background-color/font-family declarations versus the @property rule are currently different in the output than they are in the input. That's what the deprecation warning is about. Sass avoids having intimate knowledge of CSS internals where possible—it doesn't keep track of whether @property could potentially have order-sensitive semantics. But it does know that it's changing the order and that's a risk, so it tells you as much.

@nex3 nex3 closed this as not planned Won't fix, can't repro, duplicate, stale Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants