Skip to content
This repository was archived by the owner on Apr 6, 2021. It is now read-only.

Commit 73173cb

Browse files
committed
Detect non-classes with square brackets more quickly (string[])
1 parent 0797565 commit 73173cb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/lib/generateRules.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ function* candidatePermutations(candidate, lastIndex = Infinity) {
2424
let dashIdx
2525

2626
if (candidate.endsWith(']', lastIndex + 1)) {
27-
dashIdx = candidate.lastIndexOf('[') - 1
27+
let bracketIdx = candidate.lastIndexOf('[')
28+
29+
// If character before `[` isn't a dash, this isn't a dynamic class
30+
// eg. string[]
31+
dashIdx = candidate[bracketIdx - 1] === '-' ? bracketIdx - 1 : -1
2832
} else {
2933
dashIdx = candidate.lastIndexOf('-', lastIndex)
3034
}
@@ -41,6 +45,9 @@ function* candidatePermutations(candidate, lastIndex = Infinity) {
4145
yield* candidatePermutations(candidate, dashIdx - 1)
4246
}
4347

48+
// console.log(Array.from(candidatePermutations('string[]')))
49+
// process.exit()
50+
4451
function applyPrefix(matches, context) {
4552
if (matches.length === 0 || context.tailwindConfig.prefix === '') {
4653
return matches

0 commit comments

Comments
 (0)