Skip to content

Fix Dart Sass "mixed-decls" deprecation warning - #503

Draft
simonyang08 wants to merge 1 commit into
twbs:mainfrom
simonyang08:codex/rfs-474-mixed-decls-fix
Draft

Fix Dart Sass "mixed-decls" deprecation warning#503
simonyang08 wants to merge 1 commit into
twbs:mainfrom
simonyang08:codex/rfs-474-mixed-decls-fix

Conversation

@simonyang08

Copy link
Copy Markdown

Problem

Since Dart Sass 1.77.7, the SCSS engine emits a mixed-decls deprecation warning whenever a property declaration follows a nested rule at the same parent selector scope. The enable + min-media-query path of rfs's internal mixins triggered 5 such warnings per compilation (18+ across the full test suite), as called out in #474.

Root cause

@mixin _rfs-rule emits .enable-rfs &, &.enable-rfs { … } at the parent selector. @mixin _rfs-media-query-rule then emitted the static (-value) declaration as a bare @content; after that nested rule, followed by an @media { .enable-rfs &, &.enable-rfs { … } } nested rule. The declaration-after-nested-rule pattern is what Sass 1.77+ flags.

Fix

Move the static declaration out of _rfs-media-query-rule and into the caller (@mixin rfs) so it is emitted before the nested rules in source order. This:

  • silences the mixed-decls deprecation (declarations precede nested rules at the parent selector),
  • keeps the rendered CSS byte-identical (verified against every fixture in test/sass/ for both Dart Sass and PostCSS — 0/12 mismatches pre vs post).

Tests

  • New regression test test/sass-no-deprecation-warnings.js compiles every fixture in test/sass/ through Dart Sass with a custom logger and fails the build if any "mixed-decls" warning fires.
  • All 12 existing snapshot comparisons still match for both Dart Sass (result.dartsass) and PostCSS (result.postcss).
  • npm run lint (xo + stylelint) passes.

Notes

When `$rfs-class` is set to "enable" together with the default
min-media-query mode, the internal mixins `_rfs-rule` and
`_rfs-media-query-rule` both emit a `.enable-rfs &, &.enable-rfs { ... }`
nested rule at the parent selector scope. The bare `@content;` in
`_rfs-media-query-rule` then emitted the static ($rfs-value) property
declaration after those nested rules, which triggered Dart Sass's
`mixed-decls` deprecation warning starting with Sass 1.77.7
(https://sass-lang.com/d/mixed-decls).

Move the static property declaration into `rfs()` so that it is emitted
before the nested rules in source order. This preserves the byte-identical
rendered CSS for all existing tests (both Dart Sass and PostCSS paths) and
silences the warning because the declaration now precedes the nested rules.

Also add a regression test (`test/sass-no-deprecation-warnings.js`) that
compiles every fixture in `test/sass/` through Dart Sass and fails the
build if any "mixed-decls" deprecation warning is reported.

Signed-off-by: simonyang08 <ppt5928@gmail.com>
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

Successfully merging this pull request may close these issues.

Deprecation warning regarding the order of mixed nested declaration

2 participants