Skip to content

Commit 90b0253

Browse files
Sort class to end of list (#334)
This isn’t a real class but an artifact of how we want to do sorting
1 parent cdbc764 commit 90b0253

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/sorting.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ function reorderClasses(classList: string[], { env }: { env: TransformerEnv }) {
5353
? env.context.getClassOrder(classList)
5454
: getClassOrderPolyfill(classList, { env })
5555

56-
return orderedClasses.sort(([, a], [, z]) => {
56+
return orderedClasses.sort(([nameA, a], [nameZ, z]) => {
57+
// Move `...` to the end of the list
58+
if (nameA === '...' || nameA === '…') return 1
59+
if (nameZ === '...' || nameZ === '…') return -1
60+
5761
if (a === z) return 0
5862
if (a === null) return -1
5963
if (z === null) return 1

tests/format.test.ts

+8
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ let html: TestEntry[] = [
2525
tailwindPreserveDuplicates: true,
2626
},
2727
],
28+
29+
// … is moved to the end of the list
30+
['<div class="... sm:p-0 p-0"></div>', '<div class="p-0 sm:p-0 ..."></div>'],
31+
['<div class="… sm:p-0 p-0"></div>', '<div class="p-0 sm:p-0 …"></div>'],
32+
['<div class="sm:p-0 ... p-0"></div>', '<div class="p-0 sm:p-0 ..."></div>'],
33+
['<div class="sm:p-0 … p-0"></div>', '<div class="p-0 sm:p-0 …"></div>'],
34+
['<div class="sm:p-0 p-0 ..."></div>', '<div class="p-0 sm:p-0 ..."></div>'],
35+
['<div class="sm:p-0 p-0 …"></div>', '<div class="p-0 sm:p-0 …"></div>'],
2836
]
2937

3038
let css: TestEntry[] = [

0 commit comments

Comments
 (0)