rollup-plugin-react-scoped-css 1.0.0-alpha.11 → 1.0.0-alpha.12
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/css/scope-css.js +20 -11
- package/package.json +1 -1
package/dist/css/scope-css.js
CHANGED
|
@@ -26,7 +26,7 @@ const isScopePiercingPseudoSelector = (item) => {
|
|
|
26
26
|
return (item?.data?.type === "PseudoElementSelector" &&
|
|
27
27
|
(item?.data?.name === "v-deep" || item?.data?.name === "deep"));
|
|
28
28
|
};
|
|
29
|
-
const
|
|
29
|
+
const isThisScopedAttributeSelector = (item, hash) => {
|
|
30
30
|
return (item?.data?.type === "AttributeSelector" && item?.data?.name?.name === hash);
|
|
31
31
|
};
|
|
32
32
|
const isChainedSelector = (item) => {
|
|
@@ -34,11 +34,22 @@ const isChainedSelector = (item) => {
|
|
|
34
34
|
item?.data?.type === "ClassSelector" ||
|
|
35
35
|
item?.data?.type === "AttributeSelector" ||
|
|
36
36
|
item?.data?.type === "IdSelector" ||
|
|
37
|
-
item?.data?.type === "PseudoClassSelector"
|
|
37
|
+
item?.data?.type === "PseudoClassSelector" ||
|
|
38
|
+
item?.data?.type === "PseudoElementSelector") &&
|
|
38
39
|
(item?.next?.data?.type === "ClassSelector" ||
|
|
39
40
|
item?.next?.data?.type === "AttributeSelector" ||
|
|
40
41
|
item?.next?.data?.type === "IdSelector" ||
|
|
41
|
-
item?.next?.data?.type === "PseudoClassSelector"
|
|
42
|
+
item?.next?.data?.type === "PseudoClassSelector" ||
|
|
43
|
+
item?.next?.data?.type === "PseudoElementSelector"));
|
|
44
|
+
};
|
|
45
|
+
const isPseudoSelector = (item) => {
|
|
46
|
+
return (item?.data?.type === "PseudoClassSelector" ||
|
|
47
|
+
item?.data?.type === "PseudoElementSelector");
|
|
48
|
+
};
|
|
49
|
+
const isNextItemScopable = (item) => {
|
|
50
|
+
return (item?.next?.data?.type === "ClassSelector" ||
|
|
51
|
+
item?.next?.data?.type === "AttributeSelector" ||
|
|
52
|
+
item?.next?.data?.type === "IdSelector");
|
|
42
53
|
};
|
|
43
54
|
const isCombinator = (item) => {
|
|
44
55
|
return item?.data?.type === "Combinator";
|
|
@@ -61,7 +72,10 @@ function scopeCss(css, filename, hash) {
|
|
|
61
72
|
}
|
|
62
73
|
let item = selector.children.head;
|
|
63
74
|
while (item !== null) {
|
|
64
|
-
if (
|
|
75
|
+
if ((isChainedSelector(item) && isNextItemScopable(item)) ||
|
|
76
|
+
isCombinator(item) ||
|
|
77
|
+
isPseudoSelector(item) ||
|
|
78
|
+
isThisScopedAttributeSelector(item, hash)) {
|
|
65
79
|
item = item?.next ?? null;
|
|
66
80
|
continue;
|
|
67
81
|
}
|
|
@@ -69,16 +83,11 @@ function scopeCss(css, filename, hash) {
|
|
|
69
83
|
Object.assign(item.next.data, attributeSelector);
|
|
70
84
|
break;
|
|
71
85
|
}
|
|
72
|
-
if (isChainedSelector(item) || isCombinator(item)) {
|
|
73
|
-
item = item?.next ?? null;
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
86
|
if (item?.next === null) {
|
|
77
87
|
selector.children.appendData(attributeSelector);
|
|
88
|
+
break;
|
|
78
89
|
}
|
|
79
|
-
|
|
80
|
-
selector.children.insertData(attributeSelector, item.next);
|
|
81
|
-
}
|
|
90
|
+
selector.children.insertData(attributeSelector, item.next);
|
|
82
91
|
item = item?.next ?? null;
|
|
83
92
|
}
|
|
84
93
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rollup-plugin-react-scoped-css",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.12",
|
|
4
4
|
"description": "A rollup plugin designed to allow scoped css to be run in react (Compatible with vite and rollup)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|