Update processFont to handle null expressions. (#186)
* Update processFont to handle null expressions.
* Guidelines.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 071dad0..39c84cb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,7 @@
## 1.0.1-wip
-- Require Dart 3.0
+- Update `ExpressionsProcessor.processFont` to handle null expressions.
+- Require Dart 3.0.
## 1.0.0
diff --git a/lib/parser.dart b/lib/parser.dart
index e978069..837007d 100644
--- a/lib/parser.dart
+++ b/lib/parser.dart
@@ -2836,9 +2836,9 @@
}
return FontExpression(_exprs.span,
- size: fontSize!.font.size,
- lineHeight: fontSize.font.lineHeight,
- family: fontFamily!.font.family);
+ size: fontSize?.font.size,
+ lineHeight: fontSize?.font.lineHeight,
+ family: fontFamily?.font.family);
}
}
diff --git a/test/declaration_test.dart b/test/declaration_test.dart
index 5dc24f6..6406efd 100644
--- a/test/declaration_test.dart
+++ b/test/declaration_test.dart
@@ -260,6 +260,33 @@
expect(prettyPrint(stylesheet), generated);
}
+void testNoValues() {
+ var errors = <Message>[];
+ final input = r'''
+.foo {
+ color: ;
+}
+.bar {
+ font:;
+ color: blue;
+}
+''';
+
+ final generated = r'''
+.foo {
+ color: ;
+}
+.bar {
+ font: ;
+ color: #00f;
+}''';
+
+ var stylesheet = parseCss(input, errors: errors, opts: simpleOptions);
+
+ expect(errors.isEmpty, true, reason: errors.toString());
+ expect(prettyPrint(stylesheet), generated);
+}
+
void testUnicode() {
var errors = <Message>[];
final input = r'''
@@ -1435,6 +1462,7 @@
test('Identifiers', testIdentifiers);
test('Composites', testComposites);
test('Units', testUnits);
+ test('No Values', testNoValues);
test('Unicode', testUnicode);
test('Newer CSS', testNewerCss);
test('Media Queries', testMediaQueries);