@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/CHANGELOG.md
CHANGED
package/dist/compile.cjs
CHANGED
|
@@ -203,6 +203,7 @@ function buildComponentFragmentText(node, status, fragments, currentFragment) {
|
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
function buildElementFragmentText(node, status, fragments, currentFragment) {
|
|
206
|
+
let needsClass = node.scopeStyles;
|
|
206
207
|
currentFragment.text += `<${node.tagName}`;
|
|
207
208
|
let attributesText = node.attributes.filter((a) => !a.name.startsWith("on") && !a.name.includes(":")).map((a) => {
|
|
208
209
|
if (a.value && isReactive(a.value) && !a.name.includes(":")) {
|
|
@@ -210,6 +211,7 @@ function buildElementFragmentText(node, status, fragments, currentFragment) {
|
|
|
210
211
|
return `${a.name}=""`;
|
|
211
212
|
}
|
|
212
213
|
} else if (a.name === "class" && node.scopeStyles) {
|
|
214
|
+
needsClass = false;
|
|
213
215
|
let value = a.value ? `"${trimQuotes(a.value)} torp-${status.styleHash}"` : `"torp-${status.styleHash}"`;
|
|
214
216
|
return `${a.name}=${value}`;
|
|
215
217
|
} else {
|
|
@@ -219,6 +221,9 @@ function buildElementFragmentText(node, status, fragments, currentFragment) {
|
|
|
219
221
|
if (attributesText) {
|
|
220
222
|
currentFragment.text += " " + attributesText;
|
|
221
223
|
}
|
|
224
|
+
if (needsClass) {
|
|
225
|
+
currentFragment.text += ` class="torp-${status.styleHash}"`;
|
|
226
|
+
}
|
|
222
227
|
currentFragment.text += ">";
|
|
223
228
|
for (let child of node.children) {
|
|
224
229
|
buildNodeFragmentText(child, status, fragments, currentFragment);
|
|
@@ -2412,6 +2417,7 @@ function buildServerElementNode(node, status, b) {
|
|
|
2412
2417
|
}
|
|
2413
2418
|
}
|
|
2414
2419
|
function buildElementAttributes2(node, status) {
|
|
2420
|
+
let needsClass = node.scopeStyles;
|
|
2415
2421
|
let attributes = [];
|
|
2416
2422
|
for (let { name, value } of node.attributes) {
|
|
2417
2423
|
if (name === "self" && node.tagName === ":element") {
|
|
@@ -2460,6 +2466,7 @@ function buildElementAttributes2(node, status) {
|
|
|
2460
2466
|
status.imports.add("t_class");
|
|
2461
2467
|
if (node.scopeStyles) {
|
|
2462
2468
|
value += `, "torp-${status.styleHash}"`;
|
|
2469
|
+
needsClass = false;
|
|
2463
2470
|
}
|
|
2464
2471
|
attributes.push(`class="\${t_class(${value})}"`);
|
|
2465
2472
|
} else if (name === ":style") {
|
|
@@ -2477,12 +2484,16 @@ function buildElementAttributes2(node, status) {
|
|
|
2477
2484
|
} else if (name === "class" && node.scopeStyles) {
|
|
2478
2485
|
value = value ? `"${trimQuotes(value)} torp-${status.styleHash}"` : `"torp-${status.styleHash}"`;
|
|
2479
2486
|
attributes.push(`${name}="${trimQuotes(value).replaceAll('"', """)}"`);
|
|
2487
|
+
needsClass = false;
|
|
2480
2488
|
} else if (value != null) {
|
|
2481
2489
|
attributes.push(`${name}="${trimQuotes(value).replaceAll('"', """)}"`);
|
|
2482
2490
|
} else {
|
|
2483
2491
|
attributes.push(`${name}`);
|
|
2484
2492
|
}
|
|
2485
2493
|
}
|
|
2494
|
+
if (needsClass) {
|
|
2495
|
+
attributes.push(`class="torp-${status.styleHash}"`);
|
|
2496
|
+
}
|
|
2486
2497
|
return attributes.join(" ");
|
|
2487
2498
|
}
|
|
2488
2499
|
|
|
@@ -2719,6 +2730,9 @@ function buildServerTemplate(template, imports, b, options) {
|
|
|
2719
2730
|
marker = i + "/* @params */".length;
|
|
2720
2731
|
} else if (script.substring(i, i + "/* @start */".length) === "/* @start */") {
|
|
2721
2732
|
b.append(script.substring(marker, i));
|
|
2733
|
+
if (current.props?.length) {
|
|
2734
|
+
b.append(`$props ??= {};`);
|
|
2735
|
+
}
|
|
2722
2736
|
if (current.contextProps?.length) {
|
|
2723
2737
|
b.append(`$context = Object.assign({}, $context);`);
|
|
2724
2738
|
}
|