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

SASS changes in mixed declarations #1952

Open
stefanv opened this issue Aug 14, 2024 · 5 comments
Open

SASS changes in mixed declarations #1952

stefanv opened this issue Aug 14, 2024 · 5 comments
Labels
needs: more information Needs more information from the author before we can move forward tag: CSS CSS and SCSS related issues

Comments

@stefanv
Copy link

stefanv commented Aug 14, 2024

When compiling the style files from PDST using dart-sass, it emits warnings related to changes is how SASS will deal in the future with mixed declarations.

Short story, before a declaration like:

.example {
  color: red;

  a {
    font-weight: bold;
  }

  font-weight: normal;
}

Would pull font-weight to the top of .example, and define a font-weight after. Now, they leave the ordering alone.

At least the following cases are present in PDST:

_color.scss:349
_breadcrumbs.scss:30
_admonitions.scss:49
_admonitions.scss:52
_quotes.scss:24
_tables.scss:46

The workaround? As Dart Sass reports:

To keep the existing behavior, move the declaration above the nested
rule. To opt into the new behavior, wrap the declaration in & {}.

@drammock
Copy link
Collaborator

are they expected to behave differently at runtime, or only going to matter for things like readability of the compiled CSS file and/or webpack's ability to minimize file size?

Looking at the page you linked, I can see that the compiled CSS looks a bit different, but I'd expect them to behave the same way. I know later declarations can override earlier ones, but in this case .example a has greater specificity than .example so I'm not clear what difference it would make. Or is my understanding of CSS cascades simply wrong/incomplete?

@stefanv
Copy link
Author

stefanv commented Aug 14, 2024

I agree, their example doesn't illustrate any particular problem, as far as I can tell. Let me investigate a bit more; I presume they wouldn't publish it as a deprecation if it didn't have an impact.

@stefanv
Copy link
Author

stefanv commented Aug 14, 2024

I can't come up with an example right now, so I asked on the original dart-sass issue: sass/dart-sass#2267 (comment)

@trallard
Copy link
Collaborator

Thanks @stefanv - per their docs and warning this seems like a breaking change but like @drammock mentioned I do not see a clear difference if overrides hierarchy remain the same. Will note this issue as needing more information since you already pinged folks in dart-sass

@trallard trallard added tag: CSS CSS and SCSS related issues needs: more information Needs more information from the author before we can move forward labels Aug 16, 2024
@stefanv
Copy link
Author

stefanv commented Aug 17, 2024

They provided an example today:

.example {
  color: red;

  @media screen {
    font-weight: bold;
  }

  font-weight: normal;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: more information Needs more information from the author before we can move forward tag: CSS CSS and SCSS related issues
Projects
None yet
Development

No branches or pull requests

3 participants