@@ -25,33 +25,33 @@ function getClassNameFromSelector(selector) {
2525// Example with dynamic classes:
2626// ['grid-cols', '[[linename],1fr,auto]']
2727// ['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
3230
33- let dashIdx
31+ while ( lastIndex >= 0 ) {
32+ let dashIdx
3433
35- if ( lastIndex === Infinity && candidate . endsWith ( ']' ) ) {
36- let bracketIdx = candidate . indexOf ( '[' )
34+ if ( lastIndex === Infinity && candidate . endsWith ( ']' ) ) {
35+ let bracketIdx = candidate . indexOf ( '[' )
3736
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+ }
4443
45- if ( dashIdx < 0 ) {
46- return
47- }
44+ if ( dashIdx < 0 ) {
45+ break
46+ }
4847
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 )
5150
52- yield [ prefix , modifier ]
51+ yield [ prefix , modifier ]
5352
54- yield * candidatePermutations ( candidate , dashIdx - 1 )
53+ lastIndex = dashIdx - 1
54+ }
5555}
5656
5757function applyPrefix ( matches , context ) {
0 commit comments