Skip to content

Commit a077b35

Browse files
committed
Merge branch 'master' into fix/enable-optimize-universal-defaults
# Conflicts: # CHANGELOG.md # tests/apply.test.js
2 parents 8c70555 + 9c72add commit a077b35

File tree

8 files changed

+215
-69
lines changed

8 files changed

+215
-69
lines changed

CHANGELOG.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Fixed
1111

12-
- Optimize universal selectors by default ([#6906](https://github.com/tailwindlabs/tailwindcss/pull/6906))
12+
- Allow use of falsy values in theme config ([#6917](https://github.com/tailwindlabs/tailwindcss/pull/6917))
13+
- Ensure we can apply classes that are grouped with non-class selectors ([#6922](https://github.com/tailwindlabs/tailwindcss/pull/6922))
14+
- Improve standalone CLI compatibility on Linux by switching to the `linuxstatic` build target ([#6914](https://github.com/tailwindlabs/tailwindcss/pull/6914))
15+
- Optimize universal selector and default handling ([#6906](https://github.com/tailwindlabs/tailwindcss/pull/6906))
16+
1317

1418
## [3.0.11] - 2022-01-05
1519

1620
### Fixed
1721

18-
- Preserve case of css variables added by plugins ([#6888](https://github.com/tailwindlabs/tailwindcss/pull/6888))
19-
- Ignore content files that don't exist ([#6901](https://github.com/tailwindlabs/tailwindcss/pull/6901))
20-
- Revert apply defaults in isolation ([9fdc391](https://github.com/tailwindlabs/tailwindcss/commit/9fdc391d4ff93e7e350f5ce439060176b1f0162f))
22+
- Preserve casing of CSS variables added by plugins ([#6888](https://github.com/tailwindlabs/tailwindcss/pull/6888))
23+
- Ignore content paths that are passed in but don't actually exist ([#6901](https://github.com/tailwindlabs/tailwindcss/pull/6901))
24+
- Revert change that applies Tailwind's defaults in isolated environments like CSS modules ([9fdc391](https://github.com/tailwindlabs/tailwindcss/commit/9fdc391d4ff93e7e350f5ce439060176b1f0162f))
2125

2226
## [3.0.10] - 2022-01-04
2327

package-lock.json

Lines changed: 50 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"@swc/core": "^1.2.118",
4848
"@swc/jest": "^0.2.15",
4949
"@swc/register": "^0.1.7",
50-
"autoprefixer": "^10.4.0",
50+
"autoprefixer": "^10.4.1",
5151
"cross-env": "^7.0.3",
5252
"cssnano": "^5.0.14",
5353
"esbuild": "^0.14.2",
@@ -82,7 +82,7 @@
8282
"postcss-js": "^4.0.0",
8383
"postcss-load-config": "^3.1.0",
8484
"postcss-nested": "5.0.6",
85-
"postcss-selector-parser": "^6.0.7",
85+
"postcss-selector-parser": "^6.0.8",
8686
"postcss-value-parser": "^4.2.0",
8787
"quick-lru": "^5.1.1",
8888
"resolve": "^1.20.0"

src/lib/setupContextUtils.js

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,39 +89,55 @@ function getClasses(selector) {
8989
return parser.transformSync(selector)
9090
}
9191

92-
function extractCandidates(node) {
92+
function extractCandidates(node, state = { containsNonOnDemandable: false }, depth = 0) {
9393
let classes = []
9494

95+
// Handle normal rules
9596
if (node.type === 'rule') {
9697
for (let selector of node.selectors) {
9798
let classCandidates = getClasses(selector)
9899
// At least one of the selectors contains non-"on-demandable" candidates.
99-
if (classCandidates.length === 0) return []
100+
if (classCandidates.length === 0) {
101+
state.containsNonOnDemandable = true
102+
}
100103

101-
classes = [...classes, ...classCandidates]
104+
for (let classCandidate of classCandidates) {
105+
classes.push(classCandidate)
106+
}
102107
}
103-
return classes
104108
}
105109

106-
if (node.type === 'atrule') {
110+
// Handle at-rules (which contains nested rules)
111+
else if (node.type === 'atrule') {
107112
node.walkRules((rule) => {
108-
classes = [...classes, ...rule.selectors.flatMap((selector) => getClasses(selector))]
113+
for (let classCandidate of rule.selectors.flatMap((selector) =>
114+
getClasses(selector, state, depth + 1)
115+
)) {
116+
classes.push(classCandidate)
117+
}
109118
})
110119
}
111120

121+
if (depth === 0) {
122+
return [state.containsNonOnDemandable || classes.length === 0, classes]
123+
}
124+
112125
return classes
113126
}
114127

115128
function withIdentifiers(styles) {
116129
return parseStyles(styles).flatMap((node) => {
117130
let nodeMap = new Map()
118-
let candidates = extractCandidates(node)
131+
let [containsNonOnDemandableSelectors, candidates] = extractCandidates(node)
119132

120-
// If this isn't "on-demandable", assign it a universal candidate.
121-
if (candidates.length === 0) {
122-
return [['*', node]]
133+
// If this isn't "on-demandable", assign it a universal candidate to always include it.
134+
if (containsNonOnDemandableSelectors) {
135+
candidates.unshift('*')
123136
}
124137

138+
// However, it could be that it also contains "on-demandable" candidates.
139+
// E.g.: `span, .foo {}`, in that case it should still be possible to use
140+
// `@apply foo` for example.
125141
return candidates.map((c) => {
126142
if (!nodeMap.has(node)) {
127143
nodeMap.set(node, node)

src/util/pluginUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ export function coerceValue(types, modifier, options, tailwindConfig) {
185185
// Find first matching type
186186
for (let type of [].concat(types)) {
187187
let result = typeMap[type](modifier, options, { tailwindConfig })
188-
if (result) return [result, type]
188+
if (result !== undefined) return [result, type]
189189
}
190190

191191
return []

standalone-cli/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"name": "tailwindcss-standalone",
33
"version": "0.0.0",
44
"scripts": {
5-
"build": "pkg standalone.js --out-path dist --targets node16-macos-x64,node16-macos-arm64,node16-win-x64,node16-linux-x64,node16-linux-arm64 --compress Brotli --no-bytecode --public-packages \"*\" --public",
5+
"build": "pkg standalone.js --out-path dist --targets node16-macos-x64,node16-macos-arm64,node16-win-x64,node16-linuxstatic-x64,node16-linuxstatic-arm64 --compress Brotli --no-bytecode --public-packages \"*\" --public",
66
"prebuild": "rimraf dist",
7-
"postbuild": "move-file dist/standalone-macos-x64 dist/tailwindcss-macos-x64 && move-file dist/standalone-macos-arm64 dist/tailwindcss-macos-arm64 && move-file dist/standalone-win-x64.exe dist/tailwindcss-windows-x64.exe && move-file dist/standalone-linux-x64 dist/tailwindcss-linux-x64 && move-file dist/standalone-linux-arm64 dist/tailwindcss-linux-arm64",
7+
"postbuild": "move-file dist/standalone-macos-x64 dist/tailwindcss-macos-x64 && move-file dist/standalone-macos-arm64 dist/tailwindcss-macos-arm64 && move-file dist/standalone-win-x64.exe dist/tailwindcss-windows-x64.exe && move-file dist/standalone-linuxstatic-x64 dist/tailwindcss-linux-x64 && move-file dist/standalone-linuxstatic-arm64 dist/tailwindcss-linux-arm64",
88
"test": "jest"
99
},
1010
"devDependencies": {

0 commit comments

Comments
 (0)