@@ -25,33 +25,33 @@ function getClassNameFromSelector(selector) {
25
25
// Example with dynamic classes:
26
26
// ['grid-cols', '[[linename],1fr,auto]']
27
27
// ['grid', 'cols-[[linename],1fr,auto]']
28
- function * candidatePermutations ( candidate , lastIndex = Infinity ) {
29
- if ( lastIndex < 0 ) {
30
- return
31
- }
28
+ function * candidatePermutations ( candidate ) {
29
+ let lastIndex = Infinity
32
30
33
- let dashIdx
31
+ while ( lastIndex >= 0 ) {
32
+ let dashIdx
34
33
35
- if ( lastIndex === Infinity && candidate . endsWith ( ']' ) ) {
36
- let bracketIdx = candidate . indexOf ( '[' )
34
+ if ( lastIndex === Infinity && candidate . endsWith ( ']' ) ) {
35
+ let bracketIdx = candidate . indexOf ( '[' )
37
36
38
- // If character before `[` isn't a dash or a slash, this isn't a dynamic class
39
- // eg. string[]
40
- dashIdx = [ '-' , '/' ] . includes ( candidate [ bracketIdx - 1 ] ) ? bracketIdx - 1 : - 1
41
- } else {
42
- dashIdx = candidate . lastIndexOf ( '-' , lastIndex )
43
- }
37
+ // If character before `[` isn't a dash or a slash, this isn't a dynamic class
38
+ // eg. string[]
39
+ dashIdx = [ '-' , '/' ] . includes ( candidate [ bracketIdx - 1 ] ) ? bracketIdx - 1 : - 1
40
+ } else {
41
+ dashIdx = candidate . lastIndexOf ( '-' , lastIndex )
42
+ }
44
43
45
- if ( dashIdx < 0 ) {
46
- return
47
- }
44
+ if ( dashIdx < 0 ) {
45
+ break
46
+ }
48
47
49
- let prefix = candidate . slice ( 0 , dashIdx )
50
- let modifier = candidate . slice ( dashIdx + 1 )
48
+ let prefix = candidate . slice ( 0 , dashIdx )
49
+ let modifier = candidate . slice ( dashIdx + 1 )
51
50
52
- yield [ prefix , modifier ]
51
+ yield [ prefix , modifier ]
53
52
54
- yield * candidatePermutations ( candidate , dashIdx - 1 )
53
+ lastIndex = dashIdx - 1
54
+ }
55
55
}
56
56
57
57
function applyPrefix ( matches , context ) {
0 commit comments