Skip to content

Commit f1473f5

Browse files
Remove blocklisted classes from autocomplete (#10844)
* Remove blocklisted classes from autocomplete * Update changelog * Don't unnecessary loop over classes Co-authored-by: Robin Malfait <[email protected]>
1 parent eadd6e5 commit f1473f5

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2929
- Disallow multiple selectors in arbitrary variants ([#10655](https://github.com/tailwindlabs/tailwindcss/pull/10655))
3030
- Sort class lists deterministically for Prettier plugin ([#10672](https://github.com/tailwindlabs/tailwindcss/pull/10672))
3131
- Ensure CLI builds have a non-zero exit code on failure ([#10703](https://github.com/tailwindlabs/tailwindcss/pull/10703))
32+
- Remove blocklisted classes from autocomplete ([#10844](https://github.com/tailwindlabs/tailwindcss/pull/10844))
3233

3334
### Changed
3435

src/lib/setupContextUtils.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,11 @@ function registerPlugins(plugins, context) {
10071007
}
10081008
}
10091009

1010+
// Exclude utilities that are known non-classes (e.g. from the blocklist)
1011+
if (context.notClassCache.size > 0) {
1012+
output = output.filter((cls) => !context.notClassCache.has(cls))
1013+
}
1014+
10101015
return output
10111016
}
10121017

tests/getClassList.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,18 @@ crosscheck(() => {
191191
expect(classes).not.toContain('bg-red-500/50')
192192
})
193193

194+
it('should not generate utilities that are present in the blocklist', () => {
195+
let config = {
196+
blocklist: ['font-bold'],
197+
}
198+
199+
let context = createContext(resolveConfig(config))
200+
let classes = context.getClassList()
201+
202+
expect(classes).toContain('font-normal')
203+
expect(classes).not.toContain('font-bold')
204+
})
205+
194206
it('should not generate utilities that are set to undefined or null to so that they are removed', () => {
195207
let config = {
196208
theme: {

0 commit comments

Comments
 (0)