@torpor/view 0.1.1 → 0.1.3

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,18 @@
1
1
  # @torpor/view
2
2
 
3
+ ## 0.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - de51225: Fix: passing `:class` and `:style` to components
8
+
9
+ ## 0.1.2
10
+
11
+ ### Patch Changes
12
+
13
+ - 0e69292: Fix: null check
14
+ - b69fde1: Fix: replace for var names in control statements
15
+
3
16
  ## 0.1.1
4
17
 
5
18
  ### Patch Changes
package/dist/compile.cjs CHANGED
@@ -930,6 +930,17 @@ function buildComponentNode(node, status, b, root = false) {
930
930
  value = value.substring(1, value.length - 1);
931
931
  buildRun("setProp", `${propsName}["${name}"] = ${value};`, status, b);
932
932
  buildRun("setBinding", `${value} = ${propsName}["${name}"];`, status, b);
933
+ } else if (name === ":class" && value != null && isFullyReactive(value)) {
934
+ status.imports.add("t_class");
935
+ value = value.substring(1, value.length - 1);
936
+ if (node.scopeStyles) {
937
+ value += `, "torp-${status.styleHash}"`;
938
+ }
939
+ buildRun("setClasses", `${propsName}["class"] = t_class(${value});`, status, b);
940
+ } else if (name === ":style" && value != null && isFullyReactive(value)) {
941
+ status.imports.add("t_style");
942
+ value = value.substring(1, value.length - 1);
943
+ buildRun("setStyles", `${propsName}["style"] = t_style(${value});`, status, b);
933
944
  } else if (value != null) {
934
945
  let fullyReactive = isFullyReactive(value);
935
946
  let partlyReactive = isReactive(value);
@@ -1250,7 +1261,7 @@ function buildIfNode(node, status, b) {
1250
1261
  }
1251
1262
  function buildIfBranch(node, status, b, parentName, rangeName, index) {
1252
1263
  status.imports.add("t_run_branch");
1253
- b.append(`${node.statement} {`);
1264
+ b.append(`${replaceForVarNames(node.statement, status)} {`);
1254
1265
  b.append(`t_run_branch(${rangeName}, ${index}, () => {`);
1255
1266
  buildFragment(node, status, b, parentName, "t_before");
1256
1267
  status.fragmentStack.push({
@@ -1285,7 +1296,7 @@ function buildReplaceNode(node, status, b) {
1285
1296
  }
1286
1297
  function buildReplaceBranch(node, status, b, parentName, rangeName) {
1287
1298
  status.imports.add("t_run_branch");
1288
- b.append(`${node.statement};`);
1299
+ b.append(`${replaceForVarNames(node.statement, status)};`);
1289
1300
  b.append(`t_run_branch(${rangeName}, -1, () => {`);
1290
1301
  buildFragment(node, status, b, parentName, "t_before");
1291
1302
  status.fragmentStack.push({
@@ -1344,7 +1355,7 @@ function buildSwitchNode(node, status, b) {
1344
1355
  }
1345
1356
  function buildSwitchBranch(node, status, b, parentName, rangeName, index) {
1346
1357
  status.imports.add("t_run_branch");
1347
- b.append(`${node.statement} {`);
1358
+ b.append(`${replaceForVarNames(node.statement, status)} {`);
1348
1359
  b.append(`t_run_branch(${rangeName}, ${index}, () => {`);
1349
1360
  buildFragment(node, status, b, parentName, "t_before");
1350
1361
  status.fragmentStack.push({
@@ -2109,6 +2120,17 @@ function buildServerComponentNode(node, status, b) {
2109
2120
  name = name.substring(1, name.length - 1);
2110
2121
  const propName = name.split(".").at(-1);
2111
2122
  b.append(`${propsName}["${propName}"] = ${name};`);
2123
+ } else if (name === ":class" && value != null && isFullyReactive(value)) {
2124
+ status.imports.add("t_class");
2125
+ value = value.substring(1, value.length - 1);
2126
+ if (node.scopeStyles) {
2127
+ value += `, "torp-${status.styleHash}"`;
2128
+ }
2129
+ b.append(`${propsName}["class"] = t_class(${value});`);
2130
+ } else if (name === ":style" && value != null && isFullyReactive(value)) {
2131
+ status.imports.add("t_style");
2132
+ value = value.substring(1, value.length - 1);
2133
+ b.append(`${propsName}["style"] = t_style(${value});`);
2112
2134
  } else if (value != null) {
2113
2135
  let fullyReactive = isFullyReactive(value);
2114
2136
  let partlyReactive = isReactive(value);