@@ -159,7 +159,7 @@ impl<'a> Extractor<'a> {
159
159
}
160
160
161
161
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) {
163
163
ValidationResult :: Valid => return ParseAction :: SingleCandidate ( candidate) ,
164
164
ValidationResult :: Restart => return ParseAction :: RestartAt ( self . idx_start + 1 ) ,
165
165
_ => { }
@@ -240,11 +240,7 @@ impl<'a> Extractor<'a> {
240
240
}
241
241
242
242
#[ 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 {
248
244
// Reject candidates that start with a capital letter
249
245
if candidate[ 0 ] . is_ascii_uppercase ( ) {
250
246
return ValidationResult :: Invalid ;
@@ -307,14 +303,6 @@ impl<'a> Extractor<'a> {
307
303
}
308
304
}
309
305
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
-
318
306
let split_candidate = Extractor :: split_candidate ( candidate) ;
319
307
320
308
let mut offset = 0 ;
@@ -1738,44 +1726,31 @@ mod test {
1738
1726
) ;
1739
1727
}
1740
1728
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
-
1754
1729
#[ test]
1755
1730
fn test_is_valid_candidate_string ( ) {
1756
1731
assert_eq ! (
1757
- Extractor :: is_valid_candidate_string( b"foo" , b"" , 0 ) ,
1732
+ Extractor :: is_valid_candidate_string( b"foo" ) ,
1758
1733
ValidationResult :: Valid
1759
1734
) ;
1760
1735
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)" ) ,
1762
1737
ValidationResult :: Valid
1763
1738
) ;
1764
1739
assert_eq ! (
1765
- Extractor :: is_valid_candidate_string( b"bg-[url(foo)]" , b"" , 0 ) ,
1740
+ Extractor :: is_valid_candidate_string( b"bg-[url(foo)]" ) ,
1766
1741
ValidationResult :: Valid
1767
1742
) ;
1768
1743
assert_eq ! (
1769
- Extractor :: is_valid_candidate_string( b"group-foo/(--bar)" , b"" , 0 ) ,
1744
+ Extractor :: is_valid_candidate_string( b"group-foo/(--bar)" ) ,
1770
1745
ValidationResult :: Valid
1771
1746
) ;
1772
1747
1773
1748
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\" )" ) ,
1775
1750
ValidationResult :: Restart
1776
1751
) ;
1777
1752
assert_eq ! (
1778
- Extractor :: is_valid_candidate_string( b"foo-(" , b"" , 0 ) ,
1753
+ Extractor :: is_valid_candidate_string( b"foo-(" ) ,
1779
1754
ValidationResult :: Restart
1780
1755
) ;
1781
1756
}
0 commit comments