Skip to content

Commit

Permalink
test: add hardcoded list of position-sensitive modifiers to test perf…
Browse files Browse the repository at this point in the history
… of that
  • Loading branch information
dcastil committed Jan 29, 2025
1 parent 4072d8a commit 3fe7d3e
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/lib/parse-class-name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,20 @@ export const createParseClassName = (config: AnyConfig) => {
return parseClassName
}

const positionSensitiveModifiers = new Set([
'before',
'after',
'placeholder',
'file',
'marker',
'selection',
'first-line',
'first-letter',
'backdrop',
'*',
'**',
])

/**
* Sorts modifiers according to following schema:
* - Predefined modifiers are sorted alphabetically
Expand All @@ -108,9 +122,9 @@ export const sortModifiers = (modifiers: string[]) => {
let unsortedModifiers: string[] = []

modifiers.forEach((modifier) => {
const isArbitraryVariant = modifier[0] === '['
const isPositionSensitive = modifier[0] === '[' || positionSensitiveModifiers.has(modifier)

if (isArbitraryVariant) {
if (isPositionSensitive) {
sortedModifiers.push(...unsortedModifiers.sort(), modifier)
unsortedModifiers = []
} else {
Expand Down

0 comments on commit 3fe7d3e

Please sign in to comment.