@torpor/view 0.4.3 → 0.4.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 +9 -11
- package/dist/compile.cjs.map +1 -1
- package/dist/compile.js +9 -11
- package/dist/compile.js.map +1 -1
- package/package.json +1 -1
- package/src/compile/build/client/replaceForVarNames.ts +1 -1
- package/src/compile/parse/scopeStyles.ts +13 -12
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@ export default function replaceForVarNames(value: string, status: BuildStatus):
|
|
|
8
8
|
// get it from the loop data to trigger an update when it is changed
|
|
9
9
|
for (let varName of status.forVarNames) {
|
|
10
10
|
value = value.replaceAll(
|
|
11
|
-
new RegExp(`(^|\\s|\\(|\\[|\\{|!)${varName[0]}($|\\s
|
|
11
|
+
new RegExp(`(^|\\s|\\(|\\[|\\{|!)${varName[0]}($|\\s|\\.|,|\\(|\\)|\\[|\\]|\\}|;)`, "g"),
|
|
12
12
|
`$1${varName[1]}$2`,
|
|
13
13
|
);
|
|
14
14
|
}
|
|
@@ -20,24 +20,25 @@ export default function scopeStyles(status: ParseStatus): void {
|
|
|
20
20
|
|
|
21
21
|
function scopeStylesOnNode(node: TemplateNode, selectors: string[]) {
|
|
22
22
|
if (isElementNode(node) || isComponentNode(node)) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
node.scopeStyles =
|
|
24
|
+
selectors.includes(node.tagName) ||
|
|
25
|
+
node.attributes.find((a) => {
|
|
26
26
|
if (a.name === "class" && a.reactive) {
|
|
27
27
|
// Any reactivity in a class attribute makes it scoped,
|
|
28
28
|
// because we can't tell what's going on in there
|
|
29
|
-
|
|
29
|
+
return true;
|
|
30
30
|
} else if (a.name === "id" && a.value) {
|
|
31
|
-
|
|
31
|
+
if (selectors.includes(`#${trimQuotes(a.value)}`)) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
32
34
|
} else if (a.name === "class" && a.value) {
|
|
33
|
-
|
|
35
|
+
for (let classname of trimQuotes(a.value).split(/\s+/)) {
|
|
36
|
+
if (selectors.includes(`.${classname}`)) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
34
40
|
}
|
|
35
|
-
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
node.scopeStyles = scopeStyles;
|
|
41
|
+
}) !== undefined;
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
if (isParentNode(node)) {
|