Fix extracting utilities from slim/pug templates (#14006)
A class name starting with number like `2xl:bg-red-500` must not be removed. Resolves #14005
This commit is contained in:
parent
a0dbb3d876
commit
ae6a8d532b
2 changed files with 11 additions and 1 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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(`
|
||||
<div class="px-1.5 py-2.75">Hello world!</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue