diff --git a/src/lib/defaultExtractor.js b/src/lib/defaultExtractor.js index fdcd8dd5d214..8f89596313ce 100644 --- a/src/lib/defaultExtractor.js +++ b/src/lib/defaultExtractor.js @@ -32,7 +32,7 @@ export function defaultExtractor(context) { // If the next segment is a number, discard both, for example seeing // `px-1` and `5` means the real candidate was `px-1.5` which is already // captured. - let next = parseInt(segments[idx + 1]) + let next = Number(segments[idx + 1]) if (isNaN(next)) { results.push(segment) } else { diff --git a/tests/default-extractor.test.js b/tests/default-extractor.test.js index d99069197d60..0cac75d0c299 100644 --- a/tests/default-extractor.test.js +++ b/tests/default-extractor.test.js @@ -476,6 +476,16 @@ test('classes in slim templates', async () => { expect(extractions).toContain('text-gray-500') }) +test('classes in slim templates starting with number', async () => { + const extractions = defaultExtractor(` + .bg-green-300.2xl:bg-red-300 + '(Look mom, no closing tag!) + `) + + expect(extractions).toContain('bg-green-300') + expect(extractions).toContain('2xl:bg-red-300') +}) + test("classes with fractional numeric values don't also generate the whole number utility", async () => { const extractions = defaultExtractor(`
Hello world!