diff --git a/css/parser.cpp b/css/parser.cpp index c663f34b..87be1165 100644 --- a/css/parser.cpp +++ b/css/parser.cpp @@ -265,6 +265,7 @@ StyleSheet Parser::parse_rules() { media_query = MediaQuery::parse(*tmp_query); if (!media_query) { spdlog::warn("Unable to parse media query: '{}'", *tmp_query); + media_query = MediaQuery{MediaQuery::False{}}; } consume_char(); // { skip_whitespace_and_comments(); diff --git a/css/parser_test.cpp b/css/parser_test.cpp index 93ddd405..7bbc664c 100644 --- a/css/parser_test.cpp +++ b/css/parser_test.cpp @@ -296,7 +296,7 @@ int main() { etest::test("parser: bad media query", [] { auto rules = css::parse("@media (rip: 0) { p { font-size: 10px; } }").rules; auto const &rule = rules.at(0); - expect_eq(rule.media_query, std::nullopt); + expect_eq(rule.media_query, css::MediaQuery{css::MediaQuery::False{}}); expect_eq(rule.selectors, std::vector{"p"s}); require_eq(rule.declarations.size(), std::size_t{1}); expect_eq(rule.declarations.at(css::PropertyId::FontSize), "10px");