@unocss/transformer-directives 66.1.0 → 66.1.2
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/dist/index.mjs +8 -4
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -46,7 +46,7 @@ async function parseApply({ code, uno, applyVariable }, node, childNode) {
|
|
|
46
46
|
for (const i of utils) {
|
|
47
47
|
const [, _selector, body2, parent] = i;
|
|
48
48
|
const selectorOrGroup = _selector?.replace(regexScopePlaceholder, " ") || _selector;
|
|
49
|
-
if (parent || selectorOrGroup && selectorOrGroup !== ".\\-") {
|
|
49
|
+
if (parent || selectorOrGroup && selectorOrGroup !== ".\\-" && !selectorOrGroup.startsWith("@property")) {
|
|
50
50
|
let newSelector = generate(node.prelude);
|
|
51
51
|
const className = code.slice(node.prelude.loc.start.offset, node.prelude.loc.end.offset);
|
|
52
52
|
if (selectorOrGroup && selectorOrGroup !== ".\\-") {
|
|
@@ -57,8 +57,8 @@ async function parseApply({ code, uno, applyVariable }, node, childNode) {
|
|
|
57
57
|
prelude.children?.forEach((child) => {
|
|
58
58
|
const selectorListAst = clone(ruleAST.prelude);
|
|
59
59
|
const classSelectors = new List();
|
|
60
|
-
selectorListAst
|
|
61
|
-
classSelectors.appendList(selectorAst
|
|
60
|
+
selectorListAst?.children?.forEach((selectorAst) => {
|
|
61
|
+
classSelectors.appendList(selectorAst?.children?.filter((i2) => i2.type === "ClassSelector" && i2.name === "\\-"));
|
|
62
62
|
});
|
|
63
63
|
classSelectors.forEach((i2) => Object.assign(i2, clone(child)));
|
|
64
64
|
Object.assign(child, selectorListAst);
|
|
@@ -279,7 +279,11 @@ async function transformDirectives(code, uno, options, filename, originalCode, o
|
|
|
279
279
|
await Promise.all(stack);
|
|
280
280
|
const oldCode = code.toString();
|
|
281
281
|
if (!isHasApply(oldCode)) {
|
|
282
|
-
const newCode = oldCode.replace(/[^{}]
|
|
282
|
+
const newCode = oldCode.replace(/([^{}]+)\{\s*\}\s*/g, (m, selector) => {
|
|
283
|
+
if (/^[\s\w\-.,#:[\]=*"'>~+^$|()\\]+$/.test(selector.trim()))
|
|
284
|
+
return "";
|
|
285
|
+
return m;
|
|
286
|
+
});
|
|
283
287
|
if (newCode !== oldCode)
|
|
284
288
|
code.update(0, code.original.length, newCode);
|
|
285
289
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/transformer-directives",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "66.1.
|
|
4
|
+
"version": "66.1.2",
|
|
5
5
|
"description": "UnoCSS transformer for `@apply` directive",
|
|
6
6
|
"author": "hannoeru <me@hanlee.co>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"css-tree": "^3.1.0",
|
|
36
|
-
"@unocss/
|
|
37
|
-
"@unocss/
|
|
36
|
+
"@unocss/core": "66.1.2",
|
|
37
|
+
"@unocss/rule-utils": "66.1.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"magic-string": "^0.30.17"
|