tailwindcss 0.0.0-oxide-insiders.66c640b → 0.0.0-oxide-insiders.89fe09b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/lib/generateRules.js
CHANGED
|
@@ -162,12 +162,12 @@ function applyImportant(matches, classCandidate) {
|
|
|
162
162
|
]
|
|
163
163
|
});
|
|
164
164
|
container.walkRules((r)=>{
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
165
|
+
let ast = (0, _postcssSelectorParser.default)().astSync(r.selector);
|
|
166
|
+
// Remove extraneous selectors that do not include the base candidate
|
|
167
|
+
ast.each((sel)=>(0, _formatVariantSelector.eliminateIrrelevantSelectors)(sel, classCandidate));
|
|
168
|
+
// Update all instances of the base candidate to include the important marker
|
|
169
|
+
(0, _pluginUtils.updateAllClasses)(ast, (className)=>className === classCandidate ? `!${className}` : className);
|
|
170
|
+
r.selector = ast.toString();
|
|
171
171
|
r.walkDecls((d)=>d.important = true);
|
|
172
172
|
});
|
|
173
173
|
result.push([
|
|
@@ -10,6 +10,7 @@ function _export(target, all) {
|
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
12
|
formatVariantSelector: ()=>formatVariantSelector,
|
|
13
|
+
eliminateIrrelevantSelectors: ()=>eliminateIrrelevantSelectors,
|
|
13
14
|
finalizeSelector: ()=>finalizeSelector,
|
|
14
15
|
handleMergePseudo: ()=>handleMergePseudo
|
|
15
16
|
});
|
|
@@ -98,18 +99,7 @@ function formatVariantSelector(formats, { context , candidate }) {
|
|
|
98
99
|
});
|
|
99
100
|
return sel;
|
|
100
101
|
}
|
|
101
|
-
|
|
102
|
-
* Remove extraneous selectors that do not include the base class/candidate
|
|
103
|
-
*
|
|
104
|
-
* Example:
|
|
105
|
-
* Given the utility `.a, .b { color: red}`
|
|
106
|
-
* Given the candidate `sm:b`
|
|
107
|
-
*
|
|
108
|
-
* The final selector should be `.sm\:b` and not `.a, .sm\:b`
|
|
109
|
-
*
|
|
110
|
-
* @param {Selector} ast
|
|
111
|
-
* @param {string} base
|
|
112
|
-
*/ function eliminateIrrelevantSelectors(sel, base) {
|
|
102
|
+
function eliminateIrrelevantSelectors(sel, base) {
|
|
113
103
|
let hasClassesMatchingCandidate = false;
|
|
114
104
|
sel.walk((child)=>{
|
|
115
105
|
if (child.type === "class" && child.value === base) {
|
package/lib/util/pluginUtils.js
CHANGED
|
@@ -10,7 +10,6 @@ function _export(target, all) {
|
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
12
|
updateAllClasses: ()=>updateAllClasses,
|
|
13
|
-
filterSelectorsForClass: ()=>filterSelectorsForClass,
|
|
14
13
|
asValue: ()=>asValue,
|
|
15
14
|
parseColorFormat: ()=>parseColorFormat,
|
|
16
15
|
asColor: ()=>asColor,
|
|
@@ -19,7 +18,6 @@ _export(exports, {
|
|
|
19
18
|
coerceValue: ()=>coerceValue,
|
|
20
19
|
getMatchingTypes: ()=>getMatchingTypes
|
|
21
20
|
});
|
|
22
|
-
const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
|
|
23
21
|
const _escapeCommas = /*#__PURE__*/ _interopRequireDefault(require("./escapeCommas"));
|
|
24
22
|
const _withAlphaVariable = require("./withAlphaVariable");
|
|
25
23
|
const _dataTypes = require("./dataTypes");
|
|
@@ -32,29 +30,12 @@ function _interopRequireDefault(obj) {
|
|
|
32
30
|
};
|
|
33
31
|
}
|
|
34
32
|
function updateAllClasses(selectors, updateClass) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
sel.value =
|
|
39
|
-
|
|
40
|
-
sel.raws.value = (0, _escapeCommas.default)(sel.raws.value);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
let result = parser.processSync(selectors);
|
|
45
|
-
return result;
|
|
46
|
-
}
|
|
47
|
-
function filterSelectorsForClass(selectors, classCandidate) {
|
|
48
|
-
let parser = (0, _postcssSelectorParser.default)((selectors)=>{
|
|
49
|
-
selectors.each((sel)=>{
|
|
50
|
-
const containsClass = sel.nodes.some((node)=>node.type === "class" && node.value === classCandidate);
|
|
51
|
-
if (!containsClass) {
|
|
52
|
-
sel.remove();
|
|
53
|
-
}
|
|
54
|
-
});
|
|
33
|
+
selectors.walkClasses((sel)=>{
|
|
34
|
+
sel.value = updateClass(sel.value);
|
|
35
|
+
if (sel.raws && sel.raws.value) {
|
|
36
|
+
sel.raws.value = (0, _escapeCommas.default)(sel.raws.value);
|
|
37
|
+
}
|
|
55
38
|
});
|
|
56
|
-
let result = parser.processSync(selectors);
|
|
57
|
-
return result;
|
|
58
39
|
}
|
|
59
40
|
function resolveArbitraryValue(modifier, validate) {
|
|
60
41
|
if (!isArbitraryValue(modifier)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tailwindcss",
|
|
3
|
-
"version": "0.0.0-oxide-insiders.
|
|
3
|
+
"version": "0.0.0-oxide-insiders.89fe09b",
|
|
4
4
|
"description": "A utility-first CSS framework for rapidly building custom user interfaces.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"postcss": "^8.0.9"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@tailwindcss/oxide": "0.0.0-oxide-insiders.
|
|
73
|
+
"@tailwindcss/oxide": "0.0.0-oxide-insiders.89fe09b",
|
|
74
74
|
"arg": "^5.0.2",
|
|
75
75
|
"browserslist": "^4.21.5",
|
|
76
76
|
"chokidar": "^3.5.3",
|
package/src/lib/generateRules.js
CHANGED
|
@@ -3,10 +3,14 @@ import selectorParser from 'postcss-selector-parser'
|
|
|
3
3
|
import parseObjectStyles from '../util/parseObjectStyles'
|
|
4
4
|
import isPlainObject from '../util/isPlainObject'
|
|
5
5
|
import prefixSelector from '../util/prefixSelector'
|
|
6
|
-
import { updateAllClasses,
|
|
6
|
+
import { updateAllClasses, getMatchingTypes } from '../util/pluginUtils'
|
|
7
7
|
import log from '../util/log'
|
|
8
8
|
import * as sharedState from './sharedState'
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
formatVariantSelector,
|
|
11
|
+
finalizeSelector,
|
|
12
|
+
eliminateIrrelevantSelectors,
|
|
13
|
+
} from '../util/formatVariantSelector'
|
|
10
14
|
import { asClass } from '../util/nameClass'
|
|
11
15
|
import { normalize } from '../util/dataTypes'
|
|
12
16
|
import { isValidVariantFormatString, parseVariant } from './setupContextUtils'
|
|
@@ -111,22 +115,28 @@ function applyImportant(matches, classCandidate) {
|
|
|
111
115
|
if (matches.length === 0) {
|
|
112
116
|
return matches
|
|
113
117
|
}
|
|
118
|
+
|
|
114
119
|
let result = []
|
|
115
120
|
|
|
116
121
|
for (let [meta, rule] of matches) {
|
|
117
122
|
let container = postcss.root({ nodes: [rule.clone()] })
|
|
123
|
+
|
|
118
124
|
container.walkRules((r) => {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
125
|
+
let ast = selectorParser().astSync(r.selector)
|
|
126
|
+
|
|
127
|
+
// Remove extraneous selectors that do not include the base candidate
|
|
128
|
+
ast.each((sel) => eliminateIrrelevantSelectors(sel, classCandidate))
|
|
129
|
+
|
|
130
|
+
// Update all instances of the base candidate to include the important marker
|
|
131
|
+
updateAllClasses(ast, (className) =>
|
|
132
|
+
className === classCandidate ? `!${className}` : className
|
|
127
133
|
)
|
|
134
|
+
|
|
135
|
+
r.selector = ast.toString()
|
|
136
|
+
|
|
128
137
|
r.walkDecls((d) => (d.important = true))
|
|
129
138
|
})
|
|
139
|
+
|
|
130
140
|
result.push([{ ...meta, important: true }, container.nodes[0]])
|
|
131
141
|
}
|
|
132
142
|
|
|
@@ -120,7 +120,7 @@ function resortSelector(sel) {
|
|
|
120
120
|
* @param {Selector} ast
|
|
121
121
|
* @param {string} base
|
|
122
122
|
*/
|
|
123
|
-
function eliminateIrrelevantSelectors(sel, base) {
|
|
123
|
+
export function eliminateIrrelevantSelectors(sel, base) {
|
|
124
124
|
let hasClassesMatchingCandidate = false
|
|
125
125
|
|
|
126
126
|
sel.walk((child) => {
|
package/src/util/pluginUtils.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import selectorParser from 'postcss-selector-parser'
|
|
2
1
|
import escapeCommas from './escapeCommas'
|
|
3
2
|
import { withAlphaValue } from './withAlphaVariable'
|
|
4
3
|
import {
|
|
@@ -21,37 +20,19 @@ import negateValue from './negateValue'
|
|
|
21
20
|
import { backgroundSize } from './validateFormalSyntax'
|
|
22
21
|
import { flagEnabled } from '../featureFlags.js'
|
|
23
22
|
|
|
23
|
+
/**
|
|
24
|
+
* @param {import('postcss-selector-parser').Container} selectors
|
|
25
|
+
* @param {(className: string) => string} updateClass
|
|
26
|
+
* @returns {string}
|
|
27
|
+
*/
|
|
24
28
|
export function updateAllClasses(selectors, updateClass) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
let updatedClass = updateClass(sel.value)
|
|
28
|
-
sel.value = updatedClass
|
|
29
|
-
if (sel.raws && sel.raws.value) {
|
|
30
|
-
sel.raws.value = escapeCommas(sel.raws.value)
|
|
31
|
-
}
|
|
32
|
-
})
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
let result = parser.processSync(selectors)
|
|
29
|
+
selectors.walkClasses((sel) => {
|
|
30
|
+
sel.value = updateClass(sel.value)
|
|
36
31
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
export function filterSelectorsForClass(selectors, classCandidate) {
|
|
41
|
-
let parser = selectorParser((selectors) => {
|
|
42
|
-
selectors.each((sel) => {
|
|
43
|
-
const containsClass = sel.nodes.some(
|
|
44
|
-
(node) => node.type === 'class' && node.value === classCandidate
|
|
45
|
-
)
|
|
46
|
-
if (!containsClass) {
|
|
47
|
-
sel.remove()
|
|
48
|
-
}
|
|
49
|
-
})
|
|
32
|
+
if (sel.raws && sel.raws.value) {
|
|
33
|
+
sel.raws.value = escapeCommas(sel.raws.value)
|
|
34
|
+
}
|
|
50
35
|
})
|
|
51
|
-
|
|
52
|
-
let result = parser.processSync(selectors)
|
|
53
|
-
|
|
54
|
-
return result
|
|
55
36
|
}
|
|
56
37
|
|
|
57
38
|
function resolveArbitraryValue(modifier, validate) {
|