@@ -159,7 +159,7 @@ impl<'a> Extractor<'a> {
159159 }
160160
161161 while !candidate. is_empty ( ) {
162- match Extractor :: is_valid_candidate_string ( candidate, self . input , self . idx_start ) {
162+ match Extractor :: is_valid_candidate_string ( candidate) {
163163 ValidationResult :: Valid => return ParseAction :: SingleCandidate ( candidate) ,
164164 ValidationResult :: Restart => return ParseAction :: RestartAt ( self . idx_start + 1 ) ,
165165 _ => { }
@@ -240,11 +240,7 @@ impl<'a> Extractor<'a> {
240240 }
241241
242242 #[ inline( always) ]
243- fn is_valid_candidate_string (
244- candidate : & ' a [ u8 ] ,
245- input : & [ u8 ] ,
246- start_idx : usize ,
247- ) -> ValidationResult {
243+ fn is_valid_candidate_string ( candidate : & ' a [ u8 ] ) -> ValidationResult {
248244 // Reject candidates that start with a capital letter
249245 if candidate[ 0 ] . is_ascii_uppercase ( ) {
250246 return ValidationResult :: Invalid ;
@@ -307,14 +303,6 @@ impl<'a> Extractor<'a> {
307303 }
308304 }
309305
310- // CSS variables must be preceded by `var(` to be considered a valid CSS variable candidate
311- if candidate. starts_with ( b"--" ) {
312- match input. get ( start_idx - 4 ..start_idx) {
313- Some ( b"var(" ) => return ValidationResult :: Valid ,
314- _ => return ValidationResult :: Invalid ,
315- }
316- }
317-
318306 let split_candidate = Extractor :: split_candidate ( candidate) ;
319307
320308 let mut offset = 0 ;
@@ -1738,44 +1726,31 @@ mod test {
17381726 ) ;
17391727 }
17401728
1741- #[ test]
1742- fn test_css_variables_must_be_preceded_by_var_open_paren ( ) {
1743- let candidates = run ( "[--do-not-emit:true]" , false ) ;
1744- assert_eq ! (
1745- candidates,
1746- // Looks little funky, but `--do-not-emit` on its own is not emitted
1747- vec![ "[--do-not-emit:true]" , "--do-not-emit:true" ]
1748- ) ;
1749-
1750- let candidates = run ( "<div style={{ '--do-not-emit': true }}>" , false ) ;
1751- assert_eq ! ( candidates, vec![ "div" , "style" , "true" ] ) ;
1752- }
1753-
17541729 #[ test]
17551730 fn test_is_valid_candidate_string ( ) {
17561731 assert_eq ! (
1757- Extractor :: is_valid_candidate_string( b"foo" , b"" , 0 ) ,
1732+ Extractor :: is_valid_candidate_string( b"foo" ) ,
17581733 ValidationResult :: Valid
17591734 ) ;
17601735 assert_eq ! (
1761- Extractor :: is_valid_candidate_string( b"foo-(--color-red-500)" , b"" , 0 ) ,
1736+ Extractor :: is_valid_candidate_string( b"foo-(--color-red-500)" ) ,
17621737 ValidationResult :: Valid
17631738 ) ;
17641739 assert_eq ! (
1765- Extractor :: is_valid_candidate_string( b"bg-[url(foo)]" , b"" , 0 ) ,
1740+ Extractor :: is_valid_candidate_string( b"bg-[url(foo)]" ) ,
17661741 ValidationResult :: Valid
17671742 ) ;
17681743 assert_eq ! (
1769- Extractor :: is_valid_candidate_string( b"group-foo/(--bar)" , b"" , 0 ) ,
1744+ Extractor :: is_valid_candidate_string( b"group-foo/(--bar)" ) ,
17701745 ValidationResult :: Valid
17711746 ) ;
17721747
17731748 assert_eq ! (
1774- Extractor :: is_valid_candidate_string( b"foo(\" bg-red-500\" )" , b"" , 0 ) ,
1749+ Extractor :: is_valid_candidate_string( b"foo(\" bg-red-500\" )" ) ,
17751750 ValidationResult :: Restart
17761751 ) ;
17771752 assert_eq ! (
1778- Extractor :: is_valid_candidate_string( b"foo-(" , b"" , 0 ) ,
1753+ Extractor :: is_valid_candidate_string( b"foo-(" ) ,
17791754 ValidationResult :: Restart
17801755 ) ;
17811756 }
0 commit comments