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

Commit

Permalink
Merge pull request #48 from leonsenft/improve-term-errors
Browse files Browse the repository at this point in the history
Prevents exception for invalid dimension terms
  • Loading branch information
leonsenft authored May 12, 2017
2 parents e079c45 + cd6daad commit 2b4ab14
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2475,7 +2475,7 @@ class _Parser {
break;
}

return processDimension(t, value, _makeSpan(start));
return t != null ? processDimension(t, value, _makeSpan(start)) : null;
}

/** Process all dimension units. */
Expand Down
11 changes: 11 additions & 0 deletions test/declaration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ void testSimpleTerms() {
expect(stylesheet != null, true);
expect(errors.isEmpty, true, reason: errors.toString());
expect(prettyPrint(stylesheet), generated2);

// Regression test to ensure invalid percentages don't throw an exception and
// instead print a useful error message when not in checked mode.
var css = '''
.foo {
width: Infinity%;
}''';
stylesheet = parseCss(css, errors: errors..clear(), opts: simpleOptions);
expect(errors, isNotEmpty);
expect(errors.first.message, 'expected }, but found %');
expect(errors.first.span.text, '%');
}

/**
Expand Down

0 comments on commit 2b4ab14

Please sign in to comment.