Skip to content

Commit 400fab0

Browse files
committed
Support empty custom properties
See sass/sass#4078
1 parent fb429e3 commit 400fab0

File tree

9 files changed

+25
-25
lines changed

9 files changed

+25
-25
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.1-dev
1+
## 1.89.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
@@ -1371,9 +1371,12 @@ final class _EvaluateVisitor
13711371

13721372
if (node.value case var expression?) {
13731373
var value = await expression.accept(this);
1374-
// If the value is an empty list, preserve it, because converting it to CSS
1375-
// will throw an error that we want the user to see.
1376-
if (!value.isBlank || _isEmptyList(value)) {
1374+
if (!value.isBlank ||
1375+
// If the value is an empty list, preserve it, because converting it
1376+
// to CSS will throw an error that we want the user to see.
1377+
_isEmptyList(value) ||
1378+
// Custom properties are allowed to have empty values, per spec.
1379+
name.value.startsWith('--')) {
13771380
_parent.addChild(
13781381
ModifiableCssDeclaration(
13791382
name,
@@ -1386,11 +1389,6 @@ final class _EvaluateVisitor
13861389
_sourceMap ? node.value.andThen(_expressionNode)?.span : null,
13871390
),
13881391
);
1389-
} else if (name.value.startsWith('--')) {
1390-
throw _exception(
1391-
"Custom property values may not be empty.",
1392-
expression.span,
1393-
);
13941392
}
13951393
}
13961394

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: 607745b48d0737b3be112d0a8753dd87492fcc31
8+
// Checksum: 1dbe29b392b2eb2990a731741299fd2feea5491a
99
//
1010
// ignore_for_file: unused_import
1111

@@ -1379,9 +1379,12 @@ final class _EvaluateVisitor
13791379

13801380
if (node.value case var expression?) {
13811381
var value = expression.accept(this);
1382-
// If the value is an empty list, preserve it, because converting it to CSS
1383-
// will throw an error that we want the user to see.
1384-
if (!value.isBlank || _isEmptyList(value)) {
1382+
if (!value.isBlank ||
1383+
// If the value is an empty list, preserve it, because converting it
1384+
// to CSS will throw an error that we want the user to see.
1385+
_isEmptyList(value) ||
1386+
// Custom properties are allowed to have empty values, per spec.
1387+
name.value.startsWith('--')) {
13851388
_parent.addChild(
13861389
ModifiableCssDeclaration(
13871390
name,
@@ -1394,11 +1397,6 @@ final class _EvaluateVisitor
13941397
_sourceMap ? node.value.andThen(_expressionNode)?.span : null,
13951398
),
13961399
);
1397-
} else if (name.value.startsWith('--')) {
1398-
throw _exception(
1399-
"Custom property values may not be empty.",
1400-
expression.span,
1401-
);
14021400
}
14031401
}
14041402

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.1-dev
1+
## 15.6.0
22

33
* No user-visible changes.
44

pkg/sass_api/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ 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.1-dev
5+
version: 15.6.0
66
description: Additional APIs for Dart Sass.
77
homepage: https://github.com/sass/dart-sass
88

99
environment:
1010
sdk: ">=3.6.0 <4.0.0"
1111

1212
dependencies:
13-
sass: 1.88.1
13+
sass: 1.89.0
1414

1515
dev_dependencies:
1616
dartdoc: ^8.0.14

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.1-dev
2+
version: 1.89.0
33
description: A Sass implementation in Dart.
44
homepage: https://github.com/sass/dart-sass
55

0 commit comments

Comments
 (0)