@@ -15,6 +15,7 @@ use crate::keywords::{
15
15
} ;
16
16
use biome_css_syntax:: { AnyCssGenericComponentValue , AnyCssValue , CssGenericComponentValueList } ;
17
17
use biome_rowan:: { AstNode , SyntaxNodeCast } ;
18
+ use biome_string_case:: StrOnlyExtension ;
18
19
19
20
pub fn is_font_family_keyword ( value : & str ) -> bool {
20
21
BASIC_KEYWORDS . contains ( & value) || FONT_FAMILY_KEYWORDS . contains ( & value)
@@ -38,14 +39,15 @@ pub fn is_font_shorthand_keyword(value: &str) -> bool {
38
39
}
39
40
40
41
pub fn is_css_variable ( value : & str ) -> bool {
41
- value. to_lowercase ( ) . starts_with ( "var(" )
42
+ value. to_lowercase_cow ( ) . starts_with ( "var(" )
42
43
}
43
44
44
45
/// Get the font-families within a `font` shorthand property value.
45
46
pub fn find_font_family ( value : CssGenericComponentValueList ) -> Vec < AnyCssValue > {
46
47
let mut font_families: Vec < AnyCssValue > = Vec :: new ( ) ;
47
48
for v in value {
48
- let lower_case_value = v. text ( ) . to_lowercase ( ) ;
49
+ let value = v. text ( ) ;
50
+ let lower_case_value = value. to_lowercase_cow ( ) ;
49
51
50
52
// Ignore CSS variables
51
53
if is_css_variable ( & lower_case_value) {
@@ -110,7 +112,7 @@ pub fn find_font_family(value: CssGenericComponentValueList) -> Vec<AnyCssValue>
110
112
/// Check if the value is a known CSS value function.
111
113
pub fn is_function_keyword ( value : & str ) -> bool {
112
114
FUNCTION_KEYWORDS
113
- . binary_search ( & value. to_lowercase ( ) . as_str ( ) )
115
+ . binary_search ( & value. to_lowercase_cow ( ) . as_ref ( ) )
114
116
. is_ok ( )
115
117
}
116
118
@@ -178,8 +180,8 @@ pub fn vendor_prefixed(props: &str) -> bool {
178
180
179
181
/// Check if the input string is a media feature name.
180
182
pub fn is_media_feature_name ( prop : & str ) -> bool {
181
- let input = prop. to_lowercase ( ) ;
182
- let count = MEDIA_FEATURE_NAMES . binary_search ( & input. as_str ( ) ) ;
183
+ let input = prop. to_lowercase_cow ( ) ;
184
+ let count = MEDIA_FEATURE_NAMES . binary_search ( & input. as_ref ( ) ) ;
183
185
if count. is_ok ( ) {
184
186
return true ;
185
187
}
0 commit comments