Skip to content
This repository was archived by the owner on Nov 1, 2024. It is now read-only.

Commit b58e487

Browse files
authored
Update processFont to handle null expressions. (#186)
* Update processFont to handle null expressions. * Guidelines.
1 parent 62ae85e commit b58e487

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## 1.0.1-wip
22

3-
- Require Dart 3.0
3+
- Update `ExpressionsProcessor.processFont` to handle null expressions.
4+
- Require Dart 3.0.
45

56
## 1.0.0
67

lib/parser.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2836,9 +2836,9 @@ class ExpressionsProcessor {
28362836
}
28372837

28382838
return FontExpression(_exprs.span,
2839-
size: fontSize!.font.size,
2840-
lineHeight: fontSize.font.lineHeight,
2841-
family: fontFamily!.font.family);
2839+
size: fontSize?.font.size,
2840+
lineHeight: fontSize?.font.lineHeight,
2841+
family: fontFamily?.font.family);
28422842
}
28432843
}
28442844

test/declaration_test.dart

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,33 @@ void testUnits() {
260260
expect(prettyPrint(stylesheet), generated);
261261
}
262262

263+
void testNoValues() {
264+
var errors = <Message>[];
265+
final input = r'''
266+
.foo {
267+
color: ;
268+
}
269+
.bar {
270+
font:;
271+
color: blue;
272+
}
273+
''';
274+
275+
final generated = r'''
276+
.foo {
277+
color: ;
278+
}
279+
.bar {
280+
font: ;
281+
color: #00f;
282+
}''';
283+
284+
var stylesheet = parseCss(input, errors: errors, opts: simpleOptions);
285+
286+
expect(errors.isEmpty, true, reason: errors.toString());
287+
expect(prettyPrint(stylesheet), generated);
288+
}
289+
263290
void testUnicode() {
264291
var errors = <Message>[];
265292
final input = r'''
@@ -1435,6 +1462,7 @@ void main() {
14351462
test('Identifiers', testIdentifiers);
14361463
test('Composites', testComposites);
14371464
test('Units', testUnits);
1465+
test('No Values', testNoValues);
14381466
test('Unicode', testUnicode);
14391467
test('Newer CSS', testNewerCss);
14401468
test('Media Queries', testMediaQueries);

0 commit comments

Comments
 (0)