Skip to content

Commit bdc87ae

Browse files
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
1 parent d622977 commit bdc87ae

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
- Nothing yet!
10+
- Fix class detection in Slim templates with attached attributes and ID ([#14019](https://github.com/tailwindlabs/tailwindcss/pull/14019))
1111

1212
## [3.4.6] - 2024-07-16
1313

src/lib/defaultExtractor.js

+3
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ function* buildRegExps(context) {
152152
utility,
153153
])
154154
}
155+
156+
// 5. Inner matches
157+
yield /[^<>"'`\s.(){}[\]#=%$][^<>"'`\s(){}[\]#=%$]*[^<>"'`\s.(){}[\]#=%:$]/g
155158
}
156159

157160
// We want to capture any "special" characters

tests/default-extractor.test.js

+20
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,26 @@ test('classes in slim templates starting with number', async () => {
486486
expect(extractions).toContain('2xl:bg-red-300')
487487
})
488488

489+
test('classes in slim templates with attributes added', () => {
490+
let extractions = defaultExtractor(`
491+
.ml-auto[
492+
data-value='foo'
493+
]
494+
Foo bar
495+
.mr-auto[data-value='foo']
496+
Foo bar
497+
.mt-auto#omg
498+
Foo bar
499+
#omg.mb-auto
500+
Foo bar
501+
`)
502+
503+
expect(extractions).toContain(`ml-auto`)
504+
expect(extractions).toContain(`mr-auto`)
505+
expect(extractions).toContain(`mt-auto`)
506+
expect(extractions).toContain(`mb-auto`)
507+
})
508+
489509
test("classes with fractional numeric values don't also generate the whole number utility", async () => {
490510
const extractions = defaultExtractor(`
491511
<div class="px-1.5 py-2.75">Hello world!</div>

0 commit comments

Comments
 (0)