@torpor/view 0.1.4 → 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 +6 -0
- package/dist/compile.cjs +14 -10
- package/dist/compile.cjs.map +1 -1
- package/dist/compile.js +14 -10
- 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/package.json
CHANGED
|
@@ -18,20 +18,24 @@ const globalStyleRegex = /\:global\((.+)\)/;
|
|
|
18
18
|
function buildStyleBlock(block: StyleBlock, b: Builder, styleHash: string) {
|
|
19
19
|
// TODO: This should probably be done while parsing
|
|
20
20
|
// And handle attribute selectors
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
if (block.selector.startsWith("@")) {
|
|
22
|
+
// Just output media queries and properties as-is
|
|
23
|
+
b.append(`${block.selector} {`);
|
|
24
|
+
} else {
|
|
25
|
+
const selectors = block.selector
|
|
26
|
+
.split(/([\s*,>+~])/)
|
|
27
|
+
.filter((s) => !!s.trim())
|
|
28
|
+
.map((s) => {
|
|
29
|
+
if (s.length === 1 && "*,>+~".includes(s)) {
|
|
30
|
+
return s;
|
|
31
|
+
} else if (globalStyleRegex.test(s)) {
|
|
32
|
+
return s.match(globalStyleRegex)![1];
|
|
33
|
+
} else {
|
|
34
|
+
return `${s}.torp-${styleHash}`;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
b.append(`${selectors.join(" ")} {`);
|
|
38
|
+
}
|
|
35
39
|
for (let attribute of block.attributes) {
|
|
36
40
|
buildStyleAttribute(attribute, b);
|
|
37
41
|
}
|