diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a810866eb51..0b04f68dd6f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b #### Bug fixes +- Fix CSS parser case error, `@-moz-document url-prefix(https://example.com)` and `@-moz-document domain(example.com)` are now valid. Contributed by @eryue0220 - Fix [#4258](https://github.com/biomejs/biome/issues/4258), where fixed css parse error with @-moz-document url-prefix(). Contributed by @eryue0220 ### CLI @@ -89,7 +90,7 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b ) {} } ``` - + Contributed by @fireairforce - Fix [#3836](https://github.com/biomejs/biome/issues/3836), css parser allow multiple semicolons after a declaration, the following example will now parsed correctly: @@ -375,7 +376,7 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b - Fix [#3364](https://github.com/biomejs/biome/issues/3364) where the `useSelfClosingElements` rule forces the `script` tag to be self-closing. Previously, this rule applies to all elements and cannot be disabled for native HTML elements. Now, this rule accepts a `ignoreHtmlElements` option, which when set to `true`, ignores native HTML elements and allows them to be non-self-closing. - + Contributed by @abidjappie - Fix a case where raw values inside `url()` functions weren't properly trimmed. diff --git a/crates/biome_css_factory/src/generated/node_factory.rs b/crates/biome_css_factory/src/generated/node_factory.rs index c5c80247fcbe..7a186974d9b5 100644 --- a/crates/biome_css_factory/src/generated/node_factory.rs +++ b/crates/biome_css_factory/src/generated/node_factory.rs @@ -627,10 +627,10 @@ pub struct CssDocumentCustomMatcherBuilder { name_token: SyntaxToken, l_paren_token: SyntaxToken, r_paren_token: SyntaxToken, - value: Option, + value: Option, } impl CssDocumentCustomMatcherBuilder { - pub fn with_value(mut self, value: CssString) -> Self { + pub fn with_value(mut self, value: AnyCssUrlValue) -> Self { self.value = Some(value); self } diff --git a/crates/biome_css_factory/src/generated/syntax_factory.rs b/crates/biome_css_factory/src/generated/syntax_factory.rs index 8c27279ccea4..2f2fa8c3560a 100644 --- a/crates/biome_css_factory/src/generated/syntax_factory.rs +++ b/crates/biome_css_factory/src/generated/syntax_factory.rs @@ -1193,7 +1193,7 @@ impl SyntaxFactory for CssSyntaxFactory { } slots.next_slot(); if let Some(element) = ¤t_element { - if CssString::can_cast(element.kind()) { + if AnyCssUrlValue::can_cast(element.kind()) { slots.mark_present(); current_element = elements.next(); } diff --git a/crates/biome_css_parser/src/syntax/at_rule/document.rs b/crates/biome_css_parser/src/syntax/at_rule/document.rs index 4be29294084b..334e08576232 100644 --- a/crates/biome_css_parser/src/syntax/at_rule/document.rs +++ b/crates/biome_css_parser/src/syntax/at_rule/document.rs @@ -159,7 +159,11 @@ pub(crate) fn is_at_document_custom_matcher(p: &mut CssParser) -> bool { p.at_ts(DOCUMENT_CUSTOM_MATCHER_SET) && p.nth_at(1, T!['(']) } -const URL_PREFIX_SET: TokenSet = token_set!(T![url_prefix]); +// According to MDN, `url-prefix()`, `domain()` and `media-document()` functions +// can be optionally enclosed by single or double quotes. +// @see https://developer.mozilla.org/en-US/docs/Web/CSS/@document +const URL_PREFIX_SET: TokenSet = + token_set!(T![url_prefix], T![domain], T![media_document]); pub(crate) fn is_at_url_prefix(p: &mut CssParser) -> bool { p.at_ts(URL_PREFIX_SET) && p.nth_at(1, T!['(']) diff --git a/crates/biome_css_parser/tests/css_test_suite/ok/at_rule/at_rule_document.css b/crates/biome_css_parser/tests/css_test_suite/ok/at_rule/at_rule_document.css index 4ff2c264898e..1f2a3ce70fe0 100644 --- a/crates/biome_css_parser/tests/css_test_suite/ok/at_rule/at_rule_document.css +++ b/crates/biome_css_parser/tests/css_test_suite/ok/at_rule/at_rule_document.css @@ -38,3 +38,21 @@ background-color: green; } } + +@-moz-document url-prefix(https://example.com) { + body { + background-color: green; + } +} + +@-moz-document url(http://www.exmaple.org/), url-prefix(https://www.example.com/test), domain(example.com) { + body { + background-color: green; + } +} + +@-moz-document url(http://www.exmaple.org/), url-prefix(https: //www.example.com/test), domain(example.com), media-document(video) { + body { + background-color: green; + } +} diff --git a/crates/biome_css_parser/tests/css_test_suite/ok/at_rule/at_rule_document.css.snap b/crates/biome_css_parser/tests/css_test_suite/ok/at_rule/at_rule_document.css.snap index 3a6e06b547a2..308772725a82 100644 --- a/crates/biome_css_parser/tests/css_test_suite/ok/at_rule/at_rule_document.css.snap +++ b/crates/biome_css_parser/tests/css_test_suite/ok/at_rule/at_rule_document.css.snap @@ -47,6 +47,24 @@ expression: snapshot } } +@-moz-document url-prefix(https://example.com) { + body { + background-color: green; + } +} + +@-moz-document url(http://www.exmaple.org/), url-prefix(https://www.example.com/test), domain(example.com) { + body { + background-color: green; + } +} + +@-moz-document url(http://www.exmaple.org/), url-prefix(https: //www.example.com/test), domain(example.com), media-document(video) { + body { + background-color: green; + } +} + ``` @@ -558,17 +576,241 @@ CssRoot { }, }, }, + CssAtRule { + at_token: AT@820..823 "@" [Newline("\n"), Newline("\n")] [], + rule: CssDocumentAtRule { + document_token: DOCUMENT_KW@823..837 "-moz-document" [] [Whitespace(" ")], + matchers: CssDocumentMatcherList [ + CssDocumentCustomMatcher { + name: URL_PREFIX_KW@837..847 "url-prefix" [] [], + l_paren_token: L_PAREN@847..848 "(" [] [], + value: CssUrlValueRaw { + value_token: CSS_URL_VALUE_RAW_LITERAL@848..867 "https://example.com" [] [], + }, + r_paren_token: R_PAREN@867..869 ")" [] [Whitespace(" ")], + }, + ], + block: CssRuleBlock { + l_curly_token: L_CURLY@869..870 "{" [] [], + rules: CssRuleList [ + CssQualifiedRule { + prelude: CssSelectorList [ + CssCompoundSelector { + nesting_selectors: CssNestedSelectorList [], + simple_selector: CssTypeSelector { + namespace: missing (optional), + ident: CssIdentifier { + value_token: IDENT@870..877 "body" [Newline("\n"), Whitespace("\t")] [Whitespace(" ")], + }, + }, + sub_selectors: CssSubSelectorList [], + }, + ], + block: CssDeclarationOrRuleBlock { + l_curly_token: L_CURLY@877..878 "{" [] [], + items: CssDeclarationOrRuleList [ + CssDeclarationWithSemicolon { + declaration: CssDeclaration { + property: CssGenericProperty { + name: CssIdentifier { + value_token: IDENT@878..897 "background-color" [Newline("\n"), Whitespace("\t\t")] [], + }, + colon_token: COLON@897..899 ":" [] [Whitespace(" ")], + value: CssGenericComponentValueList [ + CssIdentifier { + value_token: IDENT@899..904 "green" [] [], + }, + ], + }, + important: missing (optional), + }, + semicolon_token: SEMICOLON@904..905 ";" [] [], + }, + ], + r_curly_token: R_CURLY@905..908 "}" [Newline("\n"), Whitespace("\t")] [], + }, + }, + ], + r_curly_token: R_CURLY@908..910 "}" [Newline("\n")] [], + }, + }, + }, + CssAtRule { + at_token: AT@910..913 "@" [Newline("\n"), Newline("\n")] [], + rule: CssDocumentAtRule { + document_token: DOCUMENT_KW@913..927 "-moz-document" [] [Whitespace(" ")], + matchers: CssDocumentMatcherList [ + CssUrlFunction { + name: URL_KW@927..930 "url" [] [], + l_paren_token: L_PAREN@930..931 "(" [] [], + value: CssUrlValueRaw { + value_token: CSS_URL_VALUE_RAW_LITERAL@931..954 "http://www.exmaple.org/" [] [], + }, + modifiers: CssUrlModifierList [], + r_paren_token: R_PAREN@954..955 ")" [] [], + }, + COMMA@955..957 "," [] [Whitespace(" ")], + CssDocumentCustomMatcher { + name: URL_PREFIX_KW@957..967 "url-prefix" [] [], + l_paren_token: L_PAREN@967..968 "(" [] [], + value: CssUrlValueRaw { + value_token: CSS_URL_VALUE_RAW_LITERAL@968..996 "https://www.example.com/test" [] [], + }, + r_paren_token: R_PAREN@996..997 ")" [] [], + }, + COMMA@997..999 "," [] [Whitespace(" ")], + CssDocumentCustomMatcher { + name: DOMAIN_KW@999..1005 "domain" [] [], + l_paren_token: L_PAREN@1005..1006 "(" [] [], + value: CssUrlValueRaw { + value_token: CSS_URL_VALUE_RAW_LITERAL@1006..1017 "example.com" [] [], + }, + r_paren_token: R_PAREN@1017..1019 ")" [] [Whitespace(" ")], + }, + ], + block: CssRuleBlock { + l_curly_token: L_CURLY@1019..1020 "{" [] [], + rules: CssRuleList [ + CssQualifiedRule { + prelude: CssSelectorList [ + CssCompoundSelector { + nesting_selectors: CssNestedSelectorList [], + simple_selector: CssTypeSelector { + namespace: missing (optional), + ident: CssIdentifier { + value_token: IDENT@1020..1027 "body" [Newline("\n"), Whitespace("\t")] [Whitespace(" ")], + }, + }, + sub_selectors: CssSubSelectorList [], + }, + ], + block: CssDeclarationOrRuleBlock { + l_curly_token: L_CURLY@1027..1028 "{" [] [], + items: CssDeclarationOrRuleList [ + CssDeclarationWithSemicolon { + declaration: CssDeclaration { + property: CssGenericProperty { + name: CssIdentifier { + value_token: IDENT@1028..1047 "background-color" [Newline("\n"), Whitespace("\t\t")] [], + }, + colon_token: COLON@1047..1049 ":" [] [Whitespace(" ")], + value: CssGenericComponentValueList [ + CssIdentifier { + value_token: IDENT@1049..1054 "green" [] [], + }, + ], + }, + important: missing (optional), + }, + semicolon_token: SEMICOLON@1054..1055 ";" [] [], + }, + ], + r_curly_token: R_CURLY@1055..1058 "}" [Newline("\n"), Whitespace("\t")] [], + }, + }, + ], + r_curly_token: R_CURLY@1058..1060 "}" [Newline("\n")] [], + }, + }, + }, + CssAtRule { + at_token: AT@1060..1063 "@" [Newline("\n"), Newline("\n")] [], + rule: CssDocumentAtRule { + document_token: DOCUMENT_KW@1063..1077 "-moz-document" [] [Whitespace(" ")], + matchers: CssDocumentMatcherList [ + CssUrlFunction { + name: URL_KW@1077..1080 "url" [] [], + l_paren_token: L_PAREN@1080..1081 "(" [] [], + value: CssUrlValueRaw { + value_token: CSS_URL_VALUE_RAW_LITERAL@1081..1104 "http://www.exmaple.org/" [] [], + }, + modifiers: CssUrlModifierList [], + r_paren_token: R_PAREN@1104..1105 ")" [] [], + }, + COMMA@1105..1107 "," [] [Whitespace(" ")], + CssDocumentCustomMatcher { + name: URL_PREFIX_KW@1107..1117 "url-prefix" [] [], + l_paren_token: L_PAREN@1117..1118 "(" [] [], + value: CssUrlValueRaw { + value_token: CSS_URL_VALUE_RAW_LITERAL@1118..1147 "https: //www.example.com/test" [] [], + }, + r_paren_token: R_PAREN@1147..1148 ")" [] [], + }, + COMMA@1148..1150 "," [] [Whitespace(" ")], + CssDocumentCustomMatcher { + name: DOMAIN_KW@1150..1156 "domain" [] [], + l_paren_token: L_PAREN@1156..1157 "(" [] [], + value: CssUrlValueRaw { + value_token: CSS_URL_VALUE_RAW_LITERAL@1157..1168 "example.com" [] [], + }, + r_paren_token: R_PAREN@1168..1169 ")" [] [], + }, + COMMA@1169..1171 "," [] [Whitespace(" ")], + CssDocumentCustomMatcher { + name: MEDIA_DOCUMENT_KW@1171..1185 "media-document" [] [], + l_paren_token: L_PAREN@1185..1186 "(" [] [], + value: CssUrlValueRaw { + value_token: CSS_URL_VALUE_RAW_LITERAL@1186..1191 "video" [] [], + }, + r_paren_token: R_PAREN@1191..1193 ")" [] [Whitespace(" ")], + }, + ], + block: CssRuleBlock { + l_curly_token: L_CURLY@1193..1194 "{" [] [], + rules: CssRuleList [ + CssQualifiedRule { + prelude: CssSelectorList [ + CssCompoundSelector { + nesting_selectors: CssNestedSelectorList [], + simple_selector: CssTypeSelector { + namespace: missing (optional), + ident: CssIdentifier { + value_token: IDENT@1194..1201 "body" [Newline("\n"), Whitespace("\t")] [Whitespace(" ")], + }, + }, + sub_selectors: CssSubSelectorList [], + }, + ], + block: CssDeclarationOrRuleBlock { + l_curly_token: L_CURLY@1201..1202 "{" [] [], + items: CssDeclarationOrRuleList [ + CssDeclarationWithSemicolon { + declaration: CssDeclaration { + property: CssGenericProperty { + name: CssIdentifier { + value_token: IDENT@1202..1221 "background-color" [Newline("\n"), Whitespace("\t\t")] [], + }, + colon_token: COLON@1221..1223 ":" [] [Whitespace(" ")], + value: CssGenericComponentValueList [ + CssIdentifier { + value_token: IDENT@1223..1228 "green" [] [], + }, + ], + }, + important: missing (optional), + }, + semicolon_token: SEMICOLON@1228..1229 ";" [] [], + }, + ], + r_curly_token: R_CURLY@1229..1232 "}" [Newline("\n"), Whitespace("\t")] [], + }, + }, + ], + r_curly_token: R_CURLY@1232..1234 "}" [Newline("\n")] [], + }, + }, + }, ], - eof_token: EOF@820..821 "" [Newline("\n")] [], + eof_token: EOF@1234..1235 "" [Newline("\n")] [], } ``` ## CST ``` -0: CSS_ROOT@0..821 +0: CSS_ROOT@0..1235 0: (empty) - 1: CSS_RULE_LIST@0..820 + 1: CSS_RULE_LIST@0..1234 0: CSS_AT_RULE@0..70 0: AT@0..1 "@" [] [] 1: CSS_DOCUMENT_AT_RULE@1..70 @@ -914,6 +1156,160 @@ CssRoot { 1: SEMICOLON@814..815 ";" [] [] 2: R_CURLY@815..818 "}" [Newline("\n"), Whitespace("\t")] [] 2: R_CURLY@818..820 "}" [Newline("\n")] [] - 2: EOF@820..821 "" [Newline("\n")] [] + 10: CSS_AT_RULE@820..910 + 0: AT@820..823 "@" [Newline("\n"), Newline("\n")] [] + 1: CSS_DOCUMENT_AT_RULE@823..910 + 0: DOCUMENT_KW@823..837 "-moz-document" [] [Whitespace(" ")] + 1: CSS_DOCUMENT_MATCHER_LIST@837..869 + 0: CSS_DOCUMENT_CUSTOM_MATCHER@837..869 + 0: URL_PREFIX_KW@837..847 "url-prefix" [] [] + 1: L_PAREN@847..848 "(" [] [] + 2: CSS_URL_VALUE_RAW@848..867 + 0: CSS_URL_VALUE_RAW_LITERAL@848..867 "https://example.com" [] [] + 3: R_PAREN@867..869 ")" [] [Whitespace(" ")] + 2: CSS_RULE_BLOCK@869..910 + 0: L_CURLY@869..870 "{" [] [] + 1: CSS_RULE_LIST@870..908 + 0: CSS_QUALIFIED_RULE@870..908 + 0: CSS_SELECTOR_LIST@870..877 + 0: CSS_COMPOUND_SELECTOR@870..877 + 0: CSS_NESTED_SELECTOR_LIST@870..870 + 1: CSS_TYPE_SELECTOR@870..877 + 0: (empty) + 1: CSS_IDENTIFIER@870..877 + 0: IDENT@870..877 "body" [Newline("\n"), Whitespace("\t")] [Whitespace(" ")] + 2: CSS_SUB_SELECTOR_LIST@877..877 + 1: CSS_DECLARATION_OR_RULE_BLOCK@877..908 + 0: L_CURLY@877..878 "{" [] [] + 1: CSS_DECLARATION_OR_RULE_LIST@878..905 + 0: CSS_DECLARATION_WITH_SEMICOLON@878..905 + 0: CSS_DECLARATION@878..904 + 0: CSS_GENERIC_PROPERTY@878..904 + 0: CSS_IDENTIFIER@878..897 + 0: IDENT@878..897 "background-color" [Newline("\n"), Whitespace("\t\t")] [] + 1: COLON@897..899 ":" [] [Whitespace(" ")] + 2: CSS_GENERIC_COMPONENT_VALUE_LIST@899..904 + 0: CSS_IDENTIFIER@899..904 + 0: IDENT@899..904 "green" [] [] + 1: (empty) + 1: SEMICOLON@904..905 ";" [] [] + 2: R_CURLY@905..908 "}" [Newline("\n"), Whitespace("\t")] [] + 2: R_CURLY@908..910 "}" [Newline("\n")] [] + 11: CSS_AT_RULE@910..1060 + 0: AT@910..913 "@" [Newline("\n"), Newline("\n")] [] + 1: CSS_DOCUMENT_AT_RULE@913..1060 + 0: DOCUMENT_KW@913..927 "-moz-document" [] [Whitespace(" ")] + 1: CSS_DOCUMENT_MATCHER_LIST@927..1019 + 0: CSS_URL_FUNCTION@927..955 + 0: URL_KW@927..930 "url" [] [] + 1: L_PAREN@930..931 "(" [] [] + 2: CSS_URL_VALUE_RAW@931..954 + 0: CSS_URL_VALUE_RAW_LITERAL@931..954 "http://www.exmaple.org/" [] [] + 3: CSS_URL_MODIFIER_LIST@954..954 + 4: R_PAREN@954..955 ")" [] [] + 1: COMMA@955..957 "," [] [Whitespace(" ")] + 2: CSS_DOCUMENT_CUSTOM_MATCHER@957..997 + 0: URL_PREFIX_KW@957..967 "url-prefix" [] [] + 1: L_PAREN@967..968 "(" [] [] + 2: CSS_URL_VALUE_RAW@968..996 + 0: CSS_URL_VALUE_RAW_LITERAL@968..996 "https://www.example.com/test" [] [] + 3: R_PAREN@996..997 ")" [] [] + 3: COMMA@997..999 "," [] [Whitespace(" ")] + 4: CSS_DOCUMENT_CUSTOM_MATCHER@999..1019 + 0: DOMAIN_KW@999..1005 "domain" [] [] + 1: L_PAREN@1005..1006 "(" [] [] + 2: CSS_URL_VALUE_RAW@1006..1017 + 0: CSS_URL_VALUE_RAW_LITERAL@1006..1017 "example.com" [] [] + 3: R_PAREN@1017..1019 ")" [] [Whitespace(" ")] + 2: CSS_RULE_BLOCK@1019..1060 + 0: L_CURLY@1019..1020 "{" [] [] + 1: CSS_RULE_LIST@1020..1058 + 0: CSS_QUALIFIED_RULE@1020..1058 + 0: CSS_SELECTOR_LIST@1020..1027 + 0: CSS_COMPOUND_SELECTOR@1020..1027 + 0: CSS_NESTED_SELECTOR_LIST@1020..1020 + 1: CSS_TYPE_SELECTOR@1020..1027 + 0: (empty) + 1: CSS_IDENTIFIER@1020..1027 + 0: IDENT@1020..1027 "body" [Newline("\n"), Whitespace("\t")] [Whitespace(" ")] + 2: CSS_SUB_SELECTOR_LIST@1027..1027 + 1: CSS_DECLARATION_OR_RULE_BLOCK@1027..1058 + 0: L_CURLY@1027..1028 "{" [] [] + 1: CSS_DECLARATION_OR_RULE_LIST@1028..1055 + 0: CSS_DECLARATION_WITH_SEMICOLON@1028..1055 + 0: CSS_DECLARATION@1028..1054 + 0: CSS_GENERIC_PROPERTY@1028..1054 + 0: CSS_IDENTIFIER@1028..1047 + 0: IDENT@1028..1047 "background-color" [Newline("\n"), Whitespace("\t\t")] [] + 1: COLON@1047..1049 ":" [] [Whitespace(" ")] + 2: CSS_GENERIC_COMPONENT_VALUE_LIST@1049..1054 + 0: CSS_IDENTIFIER@1049..1054 + 0: IDENT@1049..1054 "green" [] [] + 1: (empty) + 1: SEMICOLON@1054..1055 ";" [] [] + 2: R_CURLY@1055..1058 "}" [Newline("\n"), Whitespace("\t")] [] + 2: R_CURLY@1058..1060 "}" [Newline("\n")] [] + 12: CSS_AT_RULE@1060..1234 + 0: AT@1060..1063 "@" [Newline("\n"), Newline("\n")] [] + 1: CSS_DOCUMENT_AT_RULE@1063..1234 + 0: DOCUMENT_KW@1063..1077 "-moz-document" [] [Whitespace(" ")] + 1: CSS_DOCUMENT_MATCHER_LIST@1077..1193 + 0: CSS_URL_FUNCTION@1077..1105 + 0: URL_KW@1077..1080 "url" [] [] + 1: L_PAREN@1080..1081 "(" [] [] + 2: CSS_URL_VALUE_RAW@1081..1104 + 0: CSS_URL_VALUE_RAW_LITERAL@1081..1104 "http://www.exmaple.org/" [] [] + 3: CSS_URL_MODIFIER_LIST@1104..1104 + 4: R_PAREN@1104..1105 ")" [] [] + 1: COMMA@1105..1107 "," [] [Whitespace(" ")] + 2: CSS_DOCUMENT_CUSTOM_MATCHER@1107..1148 + 0: URL_PREFIX_KW@1107..1117 "url-prefix" [] [] + 1: L_PAREN@1117..1118 "(" [] [] + 2: CSS_URL_VALUE_RAW@1118..1147 + 0: CSS_URL_VALUE_RAW_LITERAL@1118..1147 "https: //www.example.com/test" [] [] + 3: R_PAREN@1147..1148 ")" [] [] + 3: COMMA@1148..1150 "," [] [Whitespace(" ")] + 4: CSS_DOCUMENT_CUSTOM_MATCHER@1150..1169 + 0: DOMAIN_KW@1150..1156 "domain" [] [] + 1: L_PAREN@1156..1157 "(" [] [] + 2: CSS_URL_VALUE_RAW@1157..1168 + 0: CSS_URL_VALUE_RAW_LITERAL@1157..1168 "example.com" [] [] + 3: R_PAREN@1168..1169 ")" [] [] + 5: COMMA@1169..1171 "," [] [Whitespace(" ")] + 6: CSS_DOCUMENT_CUSTOM_MATCHER@1171..1193 + 0: MEDIA_DOCUMENT_KW@1171..1185 "media-document" [] [] + 1: L_PAREN@1185..1186 "(" [] [] + 2: CSS_URL_VALUE_RAW@1186..1191 + 0: CSS_URL_VALUE_RAW_LITERAL@1186..1191 "video" [] [] + 3: R_PAREN@1191..1193 ")" [] [Whitespace(" ")] + 2: CSS_RULE_BLOCK@1193..1234 + 0: L_CURLY@1193..1194 "{" [] [] + 1: CSS_RULE_LIST@1194..1232 + 0: CSS_QUALIFIED_RULE@1194..1232 + 0: CSS_SELECTOR_LIST@1194..1201 + 0: CSS_COMPOUND_SELECTOR@1194..1201 + 0: CSS_NESTED_SELECTOR_LIST@1194..1194 + 1: CSS_TYPE_SELECTOR@1194..1201 + 0: (empty) + 1: CSS_IDENTIFIER@1194..1201 + 0: IDENT@1194..1201 "body" [Newline("\n"), Whitespace("\t")] [Whitespace(" ")] + 2: CSS_SUB_SELECTOR_LIST@1201..1201 + 1: CSS_DECLARATION_OR_RULE_BLOCK@1201..1232 + 0: L_CURLY@1201..1202 "{" [] [] + 1: CSS_DECLARATION_OR_RULE_LIST@1202..1229 + 0: CSS_DECLARATION_WITH_SEMICOLON@1202..1229 + 0: CSS_DECLARATION@1202..1228 + 0: CSS_GENERIC_PROPERTY@1202..1228 + 0: CSS_IDENTIFIER@1202..1221 + 0: IDENT@1202..1221 "background-color" [Newline("\n"), Whitespace("\t\t")] [] + 1: COLON@1221..1223 ":" [] [Whitespace(" ")] + 2: CSS_GENERIC_COMPONENT_VALUE_LIST@1223..1228 + 0: CSS_IDENTIFIER@1223..1228 + 0: IDENT@1223..1228 "green" [] [] + 1: (empty) + 1: SEMICOLON@1228..1229 ";" [] [] + 2: R_CURLY@1229..1232 "}" [Newline("\n"), Whitespace("\t")] [] + 2: R_CURLY@1232..1234 "}" [Newline("\n")] [] + 2: EOF@1234..1235 "" [Newline("\n")] [] ``` diff --git a/crates/biome_css_syntax/src/generated/nodes.rs b/crates/biome_css_syntax/src/generated/nodes.rs index 49c75c980c8e..658980bcc50c 100644 --- a/crates/biome_css_syntax/src/generated/nodes.rs +++ b/crates/biome_css_syntax/src/generated/nodes.rs @@ -1643,7 +1643,7 @@ impl CssDocumentCustomMatcher { pub fn l_paren_token(&self) -> SyntaxResult { support::required_token(&self.syntax, 1usize) } - pub fn value(&self) -> Option { + pub fn value(&self) -> Option { support::node(&self.syntax, 2usize) } pub fn r_paren_token(&self) -> SyntaxResult { @@ -1662,7 +1662,7 @@ impl Serialize for CssDocumentCustomMatcher { pub struct CssDocumentCustomMatcherFields { pub name: SyntaxResult, pub l_paren_token: SyntaxResult, - pub value: Option, + pub value: Option, pub r_paren_token: SyntaxResult, } #[derive(Clone, PartialEq, Eq, Hash)] diff --git a/crates/biome_css_syntax/src/generated/nodes_mut.rs b/crates/biome_css_syntax/src/generated/nodes_mut.rs index f4f85c88b095..c65bc3cea5e3 100644 --- a/crates/biome_css_syntax/src/generated/nodes_mut.rs +++ b/crates/biome_css_syntax/src/generated/nodes_mut.rs @@ -672,7 +672,7 @@ impl CssDocumentCustomMatcher { .splice_slots(1usize..=1usize, once(Some(element.into()))), ) } - pub fn with_value(self, element: Option) -> Self { + pub fn with_value(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( 2usize..=2usize, once(element.map(|element| element.into_syntax().into())), diff --git a/xtask/codegen/css.ungram b/xtask/codegen/css.ungram index fe3209e5c112..747096d4a782 100644 --- a/xtask/codegen/css.ungram +++ b/xtask/codegen/css.ungram @@ -1517,7 +1517,7 @@ AnyCssDocumentMatcher = CssDocumentCustomMatcher = name: ('url-prefix' | 'domain' | 'media-document' | 'regexp') '(' - value: CssString? + value: AnyCssUrlValue? ')' // https://github.com/css-modules/postcss-modules-values