mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Require matching prefix when detecting negatives (#8121)
* Require matching prefix when detecting negatives * Update changelog
This commit is contained in:
parent
206f1d6df5
commit
5c76de72ba
@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
- Types: allow for arbitrary theme values (for 3rd party plugins) ([#7926](https://github.com/tailwindlabs/tailwindcss/pull/7926))
|
||||
- Don’t split vars with numbers in them inside arbitrary values ([#8091](https://github.com/tailwindlabs/tailwindcss/pull/8091))
|
||||
- Require matching prefix when detecting negatives ([#8121](https://github.com/tailwindlabs/tailwindcss/pull/8121))
|
||||
|
||||
### Added
|
||||
|
||||
|
||||
@ -382,7 +382,11 @@ function* resolveMatchedPlugins(classCandidate, context) {
|
||||
const twConfigPrefix = context.tailwindConfig.prefix
|
||||
|
||||
const twConfigPrefixLen = twConfigPrefix.length
|
||||
if (candidatePrefix[twConfigPrefixLen] === '-') {
|
||||
|
||||
const hasMatchingPrefix =
|
||||
candidatePrefix.startsWith(twConfigPrefix) || candidatePrefix.startsWith(`-${twConfigPrefix}`)
|
||||
|
||||
if (candidatePrefix[twConfigPrefixLen] === '-' && hasMatchingPrefix) {
|
||||
negative = true
|
||||
candidatePrefix = twConfigPrefix + candidatePrefix.slice(twConfigPrefixLen + 1)
|
||||
}
|
||||
|
||||
@ -358,3 +358,19 @@ it('prefix with negative values and variants in the safelist', async () => {
|
||||
}
|
||||
`)
|
||||
})
|
||||
|
||||
it('prefix does not detect and generate unnecessary classes', async () => {
|
||||
let config = {
|
||||
prefix: 'tw-_',
|
||||
content: [{ raw: html`-aaa-filter aaaa-table aaaa-hidden` }],
|
||||
corePlugins: { preflight: false },
|
||||
}
|
||||
|
||||
let input = css`
|
||||
@tailwind utilities;
|
||||
`
|
||||
|
||||
const result = await run(input, config)
|
||||
|
||||
expect(result.css).toMatchFormattedCss(css``)
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user