Skip to content

Commit 5d466bc

Browse files
committed
Fix extracting utilities from slim/pug templates
A class name starting with number like `2xl:bg-red-500` must not be removed. Resolves tailwindlabs#14005
1 parent a0dbb3d commit 5d466bc

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/lib/defaultExtractor.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function defaultExtractor(context) {
3232
// If the next segment is a number, discard both, for example seeing
3333
// `px-1` and `5` means the real candidate was `px-1.5` which is already
3434
// captured.
35-
let next = parseInt(segments[idx + 1])
35+
let next = Number(segments[idx + 1])
3636
if (isNaN(next)) {
3737
results.push(segment)
3838
} else {

tests/default-extractor.test.js

+10
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,16 @@ test('classes in slim templates', async () => {
476476
expect(extractions).toContain('text-gray-500')
477477
})
478478

479+
test('classes in slim templates starting with number', async () => {
480+
const extractions = defaultExtractor(`
481+
.bg-green-300.2xl:bg-red-300
482+
'(Look mom, no closing tag!)
483+
`)
484+
485+
expect(extractions).toContain('bg-green-300')
486+
expect(extractions).toContain('2xl:bg-red-300')
487+
})
488+
479489
test("classes with fractional numeric values don't also generate the whole number utility", async () => {
480490
const extractions = defaultExtractor(`
481491
<div class="px-1.5 py-2.75">Hello world!</div>

0 commit comments

Comments
 (0)