@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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # @torpor/view
2
2
 
3
+ ## 0.0.14
4
+
5
+ ### Patch Changes
6
+
7
+ - fb896c6: Fix: make sure we've got $props on the server
8
+ - 85bccf6: Fix: apply scope to elements without a class
9
+
3
10
  ## 0.0.13
4
11
 
5
12
  ### Patch Changes
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('"', "&quot;")}"`);
2487
+ needsClass = false;
2480
2488
  } else if (value != null) {
2481
2489
  attributes.push(`${name}="${trimQuotes(value).replaceAll('"', "&quot;")}"`);
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
  }