Skip to content

Commit 5a0d95c

Browse files
authored
Document plain CSS function/mixin preparation (#1028)
See #979
1 parent 63514ee commit 5a0d95c

File tree

3 files changed

+49
-9
lines changed

3 files changed

+49
-9
lines changed

source/documentation/at-rules/function.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ introduction: >
99
---
1010

1111
Functions are defined using the `@function` at-rule, which is written `@function
12-
<name>(<arguments...>) { ... }`. A function's name can be any Sass identifier.
13-
It can only contain [universal statements][], as well as the [`@return`
14-
at-rule][] which indicates the value to use as the result of the function call.
15-
Functions are called using the normal CSS function syntax.
12+
<name>(<arguments...>) { ... }`. A function's name can be any Sass identifier
13+
that doesn't begin with `--`. It can only contain [universal statements], as
14+
well as the [`@return` at-rule] which indicates the value to use as the result
15+
of the function call. Functions are called using the normal CSS function syntax.
1616

1717
[universal statements]: /documentation/syntax/structure#universal-statements
1818
[`@return` at-rule]: #return

source/documentation/at-rules/mixin.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ introduction: >
99

1010
Mixins are defined using the `@mixin` at-rule, which is written `@mixin <name> {
1111
... }` or `@mixin name(<arguments...>) { ... }`. A mixin's name can be any Sass
12-
identifier, and it can contain any [statement][] other than [top-level
13-
statements][]. They can be used to encapsulate styles that can be dropped into a
14-
single [style rule][]; they can contain style rules of their own that can be
15-
nested in other rules or included at the top level of the stylesheet; or they
16-
can just serve to modify variables.
12+
identifier that doesn't begin with `--`, and it can contain any [statement]
13+
other than [top-level statements]. They can be used to encapsulate styles that
14+
can be dropped into a single [style rule]; they can contain style rules of their
15+
own that can be nested in other rules or included at the top level of the
16+
stylesheet; or they can just serve to modify variables.
1717

1818
[statement]: /documentation/syntax/structure#statements
1919
[top-level statements]: /documentation/syntax/structure#top-level-statements
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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

Comments
 (0)