@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/dist/compile.js CHANGED
@@ -904,6 +904,17 @@ function buildComponentNode(node, status, b, root = false) {
904
904
  value = value.substring(1, value.length - 1);
905
905
  buildRun("setProp", `${propsName}["${name}"] = ${value};`, status, b);
906
906
  buildRun("setBinding", `${value} = ${propsName}["${name}"];`, status, b);
907
+ } else if (name === ":class" && value != null && isFullyReactive(value)) {
908
+ status.imports.add("t_class");
909
+ value = value.substring(1, value.length - 1);
910
+ if (node.scopeStyles) {
911
+ value += `, "torp-${status.styleHash}"`;
912
+ }
913
+ buildRun("setClasses", `${propsName}["class"] = t_class(${value});`, status, b);
914
+ } else if (name === ":style" && value != null && isFullyReactive(value)) {
915
+ status.imports.add("t_style");
916
+ value = value.substring(1, value.length - 1);
917
+ buildRun("setStyles", `${propsName}["style"] = t_style(${value});`, status, b);
907
918
  } else if (value != null) {
908
919
  let fullyReactive = isFullyReactive(value);
909
920
  let partlyReactive = isReactive(value);
@@ -1224,7 +1235,7 @@ function buildIfNode(node, status, b) {
1224
1235
  }
1225
1236
  function buildIfBranch(node, status, b, parentName, rangeName, index) {
1226
1237
  status.imports.add("t_run_branch");
1227
- b.append(`${node.statement} {`);
1238
+ b.append(`${replaceForVarNames(node.statement, status)} {`);
1228
1239
  b.append(`t_run_branch(${rangeName}, ${index}, () => {`);
1229
1240
  buildFragment(node, status, b, parentName, "t_before");
1230
1241
  status.fragmentStack.push({
@@ -1259,7 +1270,7 @@ function buildReplaceNode(node, status, b) {
1259
1270
  }
1260
1271
  function buildReplaceBranch(node, status, b, parentName, rangeName) {
1261
1272
  status.imports.add("t_run_branch");
1262
- b.append(`${node.statement};`);
1273
+ b.append(`${replaceForVarNames(node.statement, status)};`);
1263
1274
  b.append(`t_run_branch(${rangeName}, -1, () => {`);
1264
1275
  buildFragment(node, status, b, parentName, "t_before");
1265
1276
  status.fragmentStack.push({
@@ -1318,7 +1329,7 @@ function buildSwitchNode(node, status, b) {
1318
1329
  }
1319
1330
  function buildSwitchBranch(node, status, b, parentName, rangeName, index) {
1320
1331
  status.imports.add("t_run_branch");
1321
- b.append(`${node.statement} {`);
1332
+ b.append(`${replaceForVarNames(node.statement, status)} {`);
1322
1333
  b.append(`t_run_branch(${rangeName}, ${index}, () => {`);
1323
1334
  buildFragment(node, status, b, parentName, "t_before");
1324
1335
  status.fragmentStack.push({
@@ -2083,6 +2094,17 @@ function buildServerComponentNode(node, status, b) {
2083
2094
  name = name.substring(1, name.length - 1);
2084
2095
  const propName = name.split(".").at(-1);
2085
2096
  b.append(`${propsName}["${propName}"] = ${name};`);
2097
+ } else if (name === ":class" && value != null && isFullyReactive(value)) {
2098
+ status.imports.add("t_class");
2099
+ value = value.substring(1, value.length - 1);
2100
+ if (node.scopeStyles) {
2101
+ value += `, "torp-${status.styleHash}"`;
2102
+ }
2103
+ b.append(`${propsName}["class"] = t_class(${value});`);
2104
+ } else if (name === ":style" && value != null && isFullyReactive(value)) {
2105
+ status.imports.add("t_style");
2106
+ value = value.substring(1, value.length - 1);
2107
+ b.append(`${propsName}["style"] = t_style(${value});`);
2086
2108
  } else if (value != null) {
2087
2109
  let fullyReactive = isFullyReactive(value);
2088
2110
  let partlyReactive = isReactive(value);