@torpor/view 0.0.13 → 0.0.14
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 +7 -0
- package/dist/compile.cjs +14 -0
- package/dist/compile.cjs.map +1 -1
- package/dist/compile.js +14 -0
- 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/buildFragmentText.ts +5 -0
- package/src/compile/build/server/buildServerCode.ts +5 -0
- package/src/compile/build/server/buildServerElementNode.ts +6 -0
- package/test/class/class.test.ts +6 -1
- package/test/class/components/Class.torp +5 -1
- package/test/class/components/output/Class-client.ts +2 -2
- package/test/class/components/output/Class-server.ts +1 -1
- package/test/class/components/temp/{Class-client-8c3f9e0257cc2b687e9bb7106cccbab94a4b5adf.ts → Class-client-8bf02b6a0c85674d341617dfb755b285b1af89cf.ts} +2 -2
- package/test/class/components/temp/Class-server-dd71b6ec62f40231917a912819520fc614f017ae.ts +17 -0
- package/test/class/components/temp/Class-server-2218c3284845fdab80d1a41ebace9a9e2ddd6fc1.ts +0 -17
package/dist/compile.js
CHANGED
|
@@ -177,6 +177,7 @@ function buildComponentFragmentText(node, status, fragments, currentFragment) {
|
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
function buildElementFragmentText(node, status, fragments, currentFragment) {
|
|
180
|
+
let needsClass = node.scopeStyles;
|
|
180
181
|
currentFragment.text += `<${node.tagName}`;
|
|
181
182
|
let attributesText = node.attributes.filter((a) => !a.name.startsWith("on") && !a.name.includes(":")).map((a) => {
|
|
182
183
|
if (a.value && isReactive(a.value) && !a.name.includes(":")) {
|
|
@@ -184,6 +185,7 @@ function buildElementFragmentText(node, status, fragments, currentFragment) {
|
|
|
184
185
|
return `${a.name}=""`;
|
|
185
186
|
}
|
|
186
187
|
} else if (a.name === "class" && node.scopeStyles) {
|
|
188
|
+
needsClass = false;
|
|
187
189
|
let value = a.value ? `"${trimQuotes(a.value)} torp-${status.styleHash}"` : `"torp-${status.styleHash}"`;
|
|
188
190
|
return `${a.name}=${value}`;
|
|
189
191
|
} else {
|
|
@@ -193,6 +195,9 @@ function buildElementFragmentText(node, status, fragments, currentFragment) {
|
|
|
193
195
|
if (attributesText) {
|
|
194
196
|
currentFragment.text += " " + attributesText;
|
|
195
197
|
}
|
|
198
|
+
if (needsClass) {
|
|
199
|
+
currentFragment.text += ` class="torp-${status.styleHash}"`;
|
|
200
|
+
}
|
|
196
201
|
currentFragment.text += ">";
|
|
197
202
|
for (let child of node.children) {
|
|
198
203
|
buildNodeFragmentText(child, status, fragments, currentFragment);
|
|
@@ -2386,6 +2391,7 @@ function buildServerElementNode(node, status, b) {
|
|
|
2386
2391
|
}
|
|
2387
2392
|
}
|
|
2388
2393
|
function buildElementAttributes2(node, status) {
|
|
2394
|
+
let needsClass = node.scopeStyles;
|
|
2389
2395
|
let attributes = [];
|
|
2390
2396
|
for (let { name, value } of node.attributes) {
|
|
2391
2397
|
if (name === "self" && node.tagName === ":element") {
|
|
@@ -2434,6 +2440,7 @@ function buildElementAttributes2(node, status) {
|
|
|
2434
2440
|
status.imports.add("t_class");
|
|
2435
2441
|
if (node.scopeStyles) {
|
|
2436
2442
|
value += `, "torp-${status.styleHash}"`;
|
|
2443
|
+
needsClass = false;
|
|
2437
2444
|
}
|
|
2438
2445
|
attributes.push(`class="\${t_class(${value})}"`);
|
|
2439
2446
|
} else if (name === ":style") {
|
|
@@ -2451,12 +2458,16 @@ function buildElementAttributes2(node, status) {
|
|
|
2451
2458
|
} else if (name === "class" && node.scopeStyles) {
|
|
2452
2459
|
value = value ? `"${trimQuotes(value)} torp-${status.styleHash}"` : `"torp-${status.styleHash}"`;
|
|
2453
2460
|
attributes.push(`${name}="${trimQuotes(value).replaceAll('"', """)}"`);
|
|
2461
|
+
needsClass = false;
|
|
2454
2462
|
} else if (value != null) {
|
|
2455
2463
|
attributes.push(`${name}="${trimQuotes(value).replaceAll('"', """)}"`);
|
|
2456
2464
|
} else {
|
|
2457
2465
|
attributes.push(`${name}`);
|
|
2458
2466
|
}
|
|
2459
2467
|
}
|
|
2468
|
+
if (needsClass) {
|
|
2469
|
+
attributes.push(`class="torp-${status.styleHash}"`);
|
|
2470
|
+
}
|
|
2460
2471
|
return attributes.join(" ");
|
|
2461
2472
|
}
|
|
2462
2473
|
|
|
@@ -2693,6 +2704,9 @@ function buildServerTemplate(template, imports, b, options) {
|
|
|
2693
2704
|
marker = i + "/* @params */".length;
|
|
2694
2705
|
} else if (script.substring(i, i + "/* @start */".length) === "/* @start */") {
|
|
2695
2706
|
b.append(script.substring(marker, i));
|
|
2707
|
+
if (current.props?.length) {
|
|
2708
|
+
b.append(`$props ??= {};`);
|
|
2709
|
+
}
|
|
2696
2710
|
if (current.contextProps?.length) {
|
|
2697
2711
|
b.append(`$context = Object.assign({}, $context);`);
|
|
2698
2712
|
}
|