|
| 1 | +--- |
| 2 | +title: "Breaking Change: Functions and Mixins Beginning with --" |
| 3 | +introduction: | |
| 4 | + Prior to Dart Sass 1.76.0, function and mixin names could be any valid CSS |
| 5 | + identifier, but identifiers beginning with `--` are now deprecated. |
| 6 | +--- |
| 7 | + |
| 8 | +Generally, Sass allows any valid CSS identifier to be used for any Sass |
| 9 | +definition. This includes identifiers which begin with `--`, which users may be |
| 10 | +most familiar with in the context of [CSS custom properties]. However, the CSS |
| 11 | +working group is [seriously considering] adding built-in support to CSS itself |
| 12 | +for functions and mixins, likely using at-rules named `@mixin` and `@function` |
| 13 | +just like Sass. |
| 14 | + |
| 15 | +[CSS custom properties]: https://www.w3.org/TR/css-variables-1/ |
| 16 | +[seriously considering]: https://github.com/w3c/csswg-drafts/issues/9350 |
| 17 | + |
| 18 | +This means that Sass, in order to preserve its core design principle of CSS |
| 19 | +compatibility while still supporting Sass's build-time functions and mixins, |
| 20 | +needs to be able to distinguish between CSS and Sass declarations that use the |
| 21 | +same at-rule names. Fortunately, although the details of the syntax CSS uses for |
| 22 | +functions and mixins is still very much up in the air, one point seems |
| 23 | +uncontroversial: the use of custom-property-like identifiers beginning with `--` |
| 24 | +for CSS mixin and function names. |
| 25 | + |
| 26 | +This will allow Sass to distinguish plain-CSS functions and mixins as those that |
| 27 | +begin with `--`. But in order for this to work, we first have to disallow Sass |
| 28 | +functions and mixins from using that prefix. |
| 29 | + |
| 30 | +## Transition Period |
| 31 | + |
| 32 | +{% compatibility 'dart: "1.76.0"', 'libsass: false', 'ruby: false' %}{% endcompatibility %} |
| 33 | + |
| 34 | +Between Dart Sass 1.76.0 and Dart Sass 2.0.0, Dart Sass will continue to allow |
| 35 | +functions and mixins whose names begin with `--`. However, it will emit a |
| 36 | +deprecation warning named `css-function-mixin`. |
| 37 | + |
| 38 | +Between Dart Sass 2.0.0 and the release of Dart Sass's support for plain CSS |
| 39 | +functions and mixins, functions and mixins will not be allowed to have names |
| 40 | +that begin with `--`. |
0 commit comments