@torpor/view 0.1.3 → 0.1.5
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/CHANGELOG.md +12 -0
- package/dist/compile.cjs +20 -11
- package/dist/compile.cjs.map +1 -1
- package/dist/compile.js +20 -11
- package/dist/compile.js.map +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +1 -1
- package/src/compile/build/client/buildStyles.ts +18 -14
- package/src/compile/parse/scopeStyles.ts +2 -1
- package/src/compile/types/nodes/isComponentNode.ts +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @torpor/view
|
|
2
2
|
|
|
3
|
+
## 0.1.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f390b78: Fix: don't scope media queries and CSS properties
|
|
8
|
+
|
|
9
|
+
## 0.1.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- daba2ad: Fix: passing `:class` and `:style` to components
|
|
14
|
+
|
|
3
15
|
## 0.1.3
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/compile.cjs
CHANGED
|
@@ -2083,16 +2083,20 @@ function buildStyles(style, styleHash) {
|
|
|
2083
2083
|
}
|
|
2084
2084
|
var globalStyleRegex = /\:global\((.+)\)/;
|
|
2085
2085
|
function buildStyleBlock(block, b, styleHash) {
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2086
|
+
if (block.selector.startsWith("@")) {
|
|
2087
|
+
b.append(`${block.selector} {`);
|
|
2088
|
+
} else {
|
|
2089
|
+
const selectors = block.selector.split(/([\s*,>+~])/).filter((s) => !!s.trim()).map((s) => {
|
|
2090
|
+
if (s.length === 1 && "*,>+~".includes(s)) {
|
|
2091
|
+
return s;
|
|
2092
|
+
} else if (globalStyleRegex.test(s)) {
|
|
2093
|
+
return s.match(globalStyleRegex)[1];
|
|
2094
|
+
} else {
|
|
2095
|
+
return `${s}.torp-${styleHash}`;
|
|
2096
|
+
}
|
|
2097
|
+
});
|
|
2098
|
+
b.append(`${selectors.join(" ")} {`);
|
|
2099
|
+
}
|
|
2096
2100
|
for (let attribute of block.attributes) {
|
|
2097
2101
|
buildStyleAttribute(attribute, b);
|
|
2098
2102
|
}
|
|
@@ -3666,6 +3670,11 @@ function parseStyleAttribute(status) {
|
|
|
3666
3670
|
};
|
|
3667
3671
|
}
|
|
3668
3672
|
|
|
3673
|
+
// src/compile/types/nodes/isComponentNode.ts
|
|
3674
|
+
function isComponentNode(node) {
|
|
3675
|
+
return node.type === "component";
|
|
3676
|
+
}
|
|
3677
|
+
|
|
3669
3678
|
// src/compile/types/nodes/isParentNode.ts
|
|
3670
3679
|
function isParentNode(node) {
|
|
3671
3680
|
return "children" in node;
|
|
@@ -3684,7 +3693,7 @@ function scopeStyles(status) {
|
|
|
3684
3693
|
}
|
|
3685
3694
|
}
|
|
3686
3695
|
function scopeStylesOnNode(node, selectors) {
|
|
3687
|
-
if (isElementNode(node)) {
|
|
3696
|
+
if (isElementNode(node) || isComponentNode(node)) {
|
|
3688
3697
|
let scopeStyles2 = selectors.includes(node.tagName);
|
|
3689
3698
|
if (!scopeStyles2) {
|
|
3690
3699
|
for (let a of node.attributes) {
|