Skip to content

Commit 196da17

Browse files
committed
ensure canonicalizeCandidates returns a unique list
If you use `canonicalizeCandidates(['bg-red-500', 'bg-red-500/100'])` they would both canonicalize to `bg-red-500`. No need to return duplicates here.
1 parent f6c1e15 commit 196da17

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/tailwindcss/src/canonicalize-candidates.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import { toKeyPath } from './utils/to-key-path'
88
import * as ValueParser from './value-parser'
99

1010
export function canonicalizeCandidates(ds: DesignSystem, candidates: string[]): string[] {
11-
return candidates.map((candidate) => {
12-
return canonicalizeCandidateCache.get(ds).get(candidate)
13-
})
11+
let result = new Set<string>()
12+
for (let candidate of candidates) {
13+
result.add(canonicalizeCandidateCache.get(ds).get(candidate))
14+
}
15+
return Array.from(result)
1416
}
1517

1618
const canonicalizeCandidateCache = new DefaultMap((ds: DesignSystem) => {

0 commit comments

Comments
 (0)