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

Update processFont to handle null expressions. #186

Merged
merged 3 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
6 changes: 3 additions & 3 deletions lib/parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2836,9 +2836,9 @@ class ExpressionsProcessor {
}

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);
}
}

Expand Down
28 changes: 28 additions & 0 deletions test/declaration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,33 @@ void testUnits() {
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'''
Expand Down Expand Up @@ -1435,6 +1462,7 @@ void main() {
test('Identifiers', testIdentifiers);
test('Composites', testComposites);
test('Units', testUnits);
test('No Values', testNoValues);
test('Unicode', testUnicode);
test('Newer CSS', testNewerCss);
test('Media Queries', testMediaQueries);
Expand Down