Skip to content

Commit

Permalink
Update processFont to handle null expressions. (dart-archive/csslib#186)
Browse files Browse the repository at this point in the history
* Update processFont to handle null expressions.

* Guidelines.
  • Loading branch information
ykmnkmi authored Mar 19, 2024
1 parent e897e7c commit e1a98cd
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
3 changes: 2 additions & 1 deletion pkgs/csslib/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 pkgs/csslib/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 pkgs/csslib/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

0 comments on commit e1a98cd

Please # to comment.