Skip to content

Commit deb68d5

Browse files
authored
Ensure all plugins are executed for a given candidate (#6540)
* remove early return so that all plugins are handled We had an early return so that once a plugin was matched, that we could stop running the code through the other plugins. However, in this case we have an issue that user defined css is technically also a plugin. This means that: - `bg-green-light` Would check for: - `bg-green-light` (no hit, continue) - `bg-green` (Hit! Don't execute next plugins) - `bg` (This is the one that would have generated `bg-green-light`) We tested this change and it doesn't seem to have an impact functionally and also not really performance wise. * update changelog
1 parent 08a07f6 commit deb68d5

File tree

3 files changed

+40
-4
lines changed

3 files changed

+40
-4
lines changed

CHANGELOG.md

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

88
## [Unreleased]
99

10-
- Nothing yet!
10+
### Fixed
11+
12+
- Support square bracket notation in paths ([#6519](https://github.com/tailwindlabs/tailwindcss/pull/6519))
13+
- Ensure all plugins are executed for a given candidate ([#6540](https://github.com/tailwindlabs/tailwindcss/pull/6540))
1114

1215
## [3.0.5] - 2021-12-15
1316

@@ -35,7 +38,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3538
- Fix text decoration utilities from overriding the new text decoration color/style/thickness utilities when used with a modifier ([#6378](https://github.com/tailwindlabs/tailwindcss/pull/6378))
3639
- Move defaults to their own always-on layer ([#6500](https://github.com/tailwindlabs/tailwindcss/pull/6500))
3740
- Support negative values in safelist patterns ([#6480](https://github.com/tailwindlabs/tailwindcss/pull/6480))
38-
- Support square bracket notation in paths ([#6519](https://github.com/tailwindlabs/tailwindcss/pull/6519))
3941

4042
## [3.0.2] - 2021-12-13
4143

src/lib/generateRules.js

-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,6 @@ function* resolveMatchedPlugins(classCandidate, context) {
325325
for (let [prefix, modifier] of candidatePermutations(candidatePrefix)) {
326326
if (context.candidateRuleMap.has(prefix)) {
327327
yield [context.candidateRuleMap.get(prefix), negative ? `-${modifier}` : modifier]
328-
return
329328
}
330329
}
331330
}

tests/basic-usage.test.js

+36-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'fs'
22
import path from 'path'
33

4-
import { run, css } from './util/run'
4+
import { html, run, css } from './util/run'
55

66
test('basic usage', () => {
77
let config = {
@@ -22,3 +22,38 @@ test('basic usage', () => {
2222
expect(result.css).toMatchFormattedCss(expected)
2323
})
2424
})
25+
26+
test('all plugins are executed that match a candidate', () => {
27+
let config = {
28+
content: [{ raw: html`<div class="bg-green-light bg-green"></div>` }],
29+
theme: {
30+
colors: {
31+
green: {
32+
light: 'green',
33+
},
34+
},
35+
},
36+
corePlugins: { preflight: false },
37+
}
38+
39+
let input = css`
40+
@tailwind utilities;
41+
42+
.bg-green {
43+
/* Empty on purpose */
44+
}
45+
`
46+
47+
return run(input, config).then((result) => {
48+
expect(result.css).toMatchFormattedCss(css`
49+
.bg-green-light {
50+
--tw-bg-opacity: 1;
51+
background-color: rgb(0 128 0 / var(--tw-bg-opacity));
52+
}
53+
54+
.bg-green {
55+
/* Empty on purpose */
56+
}
57+
`)
58+
})
59+
})

0 commit comments

Comments
 (0)