Skip to content

Commit 68e3dbd

Browse files
committed
Error on invalid tokens
Fixes parcel-bundler#427. Closes parcel-bundler#449
1 parent 48841f7 commit 68e3dbd

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23770,6 +23770,18 @@ mod tests {
2377023770
)
2377123771
}
2377223772

23773+
#[test]
23774+
fn test_invalid() {
23775+
error_test(
23776+
".a{color: hsla(120, 62.32%;}",
23777+
ParserError::UnexpectedToken(Token::CloseCurlyBracket),
23778+
);
23779+
error_test(
23780+
".a{--foo: url(foo\\) b\\)ar)}",
23781+
ParserError::UnexpectedToken(Token::BadUrl("foo\\) b\\)ar".into())),
23782+
);
23783+
}
23784+
2377323785
#[test]
2377423786
fn test_container_queries() {
2377523787
// with name

src/properties/custom.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,12 @@ impl<'i> TokenList<'i> {
430430
last_is_delim = false;
431431
last_is_whitespace = false;
432432
}
433+
Ok(token) if token.is_parse_error() => {
434+
return Err(ParseError {
435+
kind: ParseErrorKind::Basic(BasicParseErrorKind::UnexpectedToken(token.clone())),
436+
location: state.source_location(),
437+
})
438+
}
433439
Ok(token) => {
434440
last_is_delim = matches!(token, cssparser::Token::Delim(_) | cssparser::Token::Comma);
435441

0 commit comments

Comments
 (0)