Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Only special-case @ once
  • Loading branch information
philipp-spiess committed Apr 10, 2025
commit aec5672a45765343dd03740e422c18f5e40da86a
12 changes: 2 additions & 10 deletions packages/tailwindcss/src/candidate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -745,14 +745,6 @@ function* findRoots(input: string, exists: (input: string) => boolean): Iterable
// Otherwise test every permutation of the input by iteratively removing
// everything after the last dash.
let idx = input.lastIndexOf('-')
if (idx === -1) {
// Variants starting with `@` are special because they don't need a `-`
// after the `@` (E.g.: `@-lg` should be written as `@lg`).
if (input[0] === '@' && exists('@')) {
yield ['@', input.slice(1)]
}
return
}

// Determine the root and value by testing permutations of the incoming input.
//
Expand All @@ -761,7 +753,7 @@ function* findRoots(input: string, exists: (input: string) => boolean): Iterable
// `bg-red-500` -> No match
// `bg-red` -> No match
// `bg` -> Match
do {
while (idx > 0) {
let maybeRoot = input.slice(0, idx)

if (exists(maybeRoot)) {
Expand All @@ -776,7 +768,7 @@ function* findRoots(input: string, exists: (input: string) => boolean): Iterable
}

idx = input.lastIndexOf('-', idx - 1)
} while (idx > 0)
}

// Try '@' variant after permutations. This allows things like `@max` of `@max-foo-bar`
// to match before looking for `@`.
Expand Down