Fix class detection in Slim templates with attached attributes and IDs (#14019)

* Fix class detection in Slim templates with attached attributes and IDs

* Update changelog

* Tweak regex
This commit is contained in:
Jordan Pittman 2024-07-18 11:21:20 -04:00 committed by GitHub
parent d622977b2a
commit bdc87ae1d7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 1 deletions

View File

@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
- Nothing yet!
- Fix class detection in Slim templates with attached attributes and ID ([#14019](https://github.com/tailwindlabs/tailwindcss/pull/14019))
## [3.4.6] - 2024-07-16

View File

@ -152,6 +152,9 @@ function* buildRegExps(context) {
utility,
])
}
// 5. Inner matches
yield /[^<>"'`\s.(){}[\]#=%$][^<>"'`\s(){}[\]#=%$]*[^<>"'`\s.(){}[\]#=%:$]/g
}
// We want to capture any "special" characters

View File

@ -486,6 +486,26 @@ test('classes in slim templates starting with number', async () => {
expect(extractions).toContain('2xl:bg-red-300')
})
test('classes in slim templates with attributes added', () => {
let extractions = defaultExtractor(`
.ml-auto[
data-value='foo'
]
Foo bar
.mr-auto[data-value='foo']
Foo bar
.mt-auto#omg
Foo bar
#omg.mb-auto
Foo bar
`)
expect(extractions).toContain(`ml-auto`)
expect(extractions).toContain(`mr-auto`)
expect(extractions).toContain(`mt-auto`)
expect(extractions).toContain(`mb-auto`)
})
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>