Skip to content

Commit 6edc11e

Browse files
committed
Support empty custom properties
See sass/sass#4078
1 parent a81cd73 commit 6edc11e

File tree

9 files changed

+24
-24
lines changed

9 files changed

+24
-24
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
## 1.88.0-dev
1+
## 1.88.0
2+
3+
* Allow custom properties with empty values (such as `--var:;`).
24

35
* Fix a bug when calculating source spans for interpolations.
46

lib/src/parse/stylesheet.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,9 @@ abstract class StylesheetParser extends Parser {
412412
var name = nameBuffer.interpolation(scanner.spanFrom(start, beforeColon));
413413
if (name.initialPlain.startsWith('--')) {
414414
var value = StringExpression(
415-
_interpolatedDeclarationValue(silentComments: false),
415+
atEndOfStatement()
416+
? Interpolation(const [], const [], scanner.emptySpan)
417+
: _interpolatedDeclarationValue(silentComments: false),
416418
);
417419
expectStatementSeparator("custom property");
418420
return Declaration(name, value, scanner.spanFrom(start));

lib/src/visitor/async_evaluate.dart

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,9 +1381,12 @@ final class _EvaluateVisitor
13811381

13821382
if (node.value case var expression?) {
13831383
var value = await expression.accept(this);
1384-
// If the value is an empty list, preserve it, because converting it to CSS
1385-
// will throw an error that we want the user to see.
1386-
if (!value.isBlank || _isEmptyList(value)) {
1384+
if (!value.isBlank ||
1385+
// If the value is an empty list, preserve it, because converting it
1386+
// to CSS will throw an error that we want the user to see.
1387+
_isEmptyList(value) ||
1388+
// Custom properties are allowed to have empty values, per spec.
1389+
name.value.startsWith('--')) {
13871390
_parent.addChild(
13881391
ModifiableCssDeclaration(
13891392
name,
@@ -1396,11 +1399,6 @@ final class _EvaluateVisitor
13961399
_sourceMap ? node.value.andThen(_expressionNode)?.span : null,
13971400
),
13981401
);
1399-
} else if (name.value.startsWith('--')) {
1400-
throw _exception(
1401-
"Custom property values may not be empty.",
1402-
expression.span,
1403-
);
14041402
}
14051403
}
14061404

lib/src/visitor/evaluate.dart

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// DO NOT EDIT. This file was generated from async_evaluate.dart.
66
// See tool/grind/synchronize.dart for details.
77
//
8-
// Checksum: 6e5710daa106ed0b9b684af8bc61ce9cc233a10b
8+
// Checksum: a3068d04660dd2bed34b884aa6e1a21d423dc4e5
99
//
1010
// ignore_for_file: unused_import
1111

@@ -1389,9 +1389,12 @@ final class _EvaluateVisitor
13891389

13901390
if (node.value case var expression?) {
13911391
var value = expression.accept(this);
1392-
// If the value is an empty list, preserve it, because converting it to CSS
1393-
// will throw an error that we want the user to see.
1394-
if (!value.isBlank || _isEmptyList(value)) {
1392+
if (!value.isBlank ||
1393+
// If the value is an empty list, preserve it, because converting it
1394+
// to CSS will throw an error that we want the user to see.
1395+
_isEmptyList(value) ||
1396+
// Custom properties are allowed to have empty values, per spec.
1397+
name.value.startsWith('--')) {
13951398
_parent.addChild(
13961399
ModifiableCssDeclaration(
13971400
name,
@@ -1404,11 +1407,6 @@ final class _EvaluateVisitor
14041407
_sourceMap ? node.value.andThen(_expressionNode)?.span : null,
14051408
),
14061409
);
1407-
} else if (name.value.startsWith('--')) {
1408-
throw _exception(
1409-
"Custom property values may not be empty.",
1410-
expression.span,
1411-
);
14121410
}
14131411
}
14141412

pkg/sass-parser/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## 0.4.21-dev
1+
## 0.4.21
22

33
* No user-visible changes.
44

pkg/sass-parser/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sass-parser",
3-
"version": "0.4.21-dev",
3+
"version": "0.4.21",
44
"description": "A PostCSS-compatible wrapper of the official Sass parser",
55
"repository": "sass/sass",
66
"author": "Google Inc.",

pkg/sass_api/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## 15.5.0-dev
1+
## 15.5.0
22

33
* No user-visible changes.
44

pkg/sass_api/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: sass_api
22
# Note: Every time we add a new Sass AST node, we need to bump the *major*
33
# version because it's a breaking change for anyone who's implementing the
44
# visitor interface(s).
5-
version: 15.5.0-dev
5+
version: 15.5.0
66
description: Additional APIs for Dart Sass.
77
homepage: https://github.com/sass/dart-sass
88

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sass
2-
version: 1.88.0-dev
2+
version: 1.88.0
33
description: A Sass implementation in Dart.
44
homepage: https://github.com/sass/dart-sass
55

0 commit comments

Comments
 (0)