@torpor/view 0.1.0 → 0.1.2

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,20 @@
1
1
  # @torpor/view
2
2
 
3
+ ## 0.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 0e69292: Fix: null check
8
+ - b69fde1: Fix: replace for var names in control statements
9
+
10
+ ## 0.1.1
11
+
12
+ ### Patch Changes
13
+
14
+ - f9fd76d: Fix: make sure an animated element has been added
15
+ - 1ddc240: Fix: delay $mount effects until after hydrating
16
+ - 7b9dc31: Fix: bind refs first, so they can be used in attributes
17
+
3
18
  ## 0.1.0
4
19
 
5
20
  ### Minor Changes
package/dist/compile.cjs CHANGED
@@ -1250,7 +1250,7 @@ function buildIfNode(node, status, b) {
1250
1250
  }
1251
1251
  function buildIfBranch(node, status, b, parentName, rangeName, index) {
1252
1252
  status.imports.add("t_run_branch");
1253
- b.append(`${node.statement} {`);
1253
+ b.append(`${replaceForVarNames(node.statement, status)} {`);
1254
1254
  b.append(`t_run_branch(${rangeName}, ${index}, () => {`);
1255
1255
  buildFragment(node, status, b, parentName, "t_before");
1256
1256
  status.fragmentStack.push({
@@ -1285,7 +1285,7 @@ function buildReplaceNode(node, status, b) {
1285
1285
  }
1286
1286
  function buildReplaceBranch(node, status, b, parentName, rangeName) {
1287
1287
  status.imports.add("t_run_branch");
1288
- b.append(`${node.statement};`);
1288
+ b.append(`${replaceForVarNames(node.statement, status)};`);
1289
1289
  b.append(`t_run_branch(${rangeName}, -1, () => {`);
1290
1290
  buildFragment(node, status, b, parentName, "t_before");
1291
1291
  status.fragmentStack.push({
@@ -1344,7 +1344,7 @@ function buildSwitchNode(node, status, b) {
1344
1344
  }
1345
1345
  function buildSwitchBranch(node, status, b, parentName, rangeName, index) {
1346
1346
  status.imports.add("t_run_branch");
1347
- b.append(`${node.statement} {`);
1347
+ b.append(`${replaceForVarNames(node.statement, status)} {`);
1348
1348
  b.append(`t_run_branch(${rangeName}, ${index}, () => {`);
1349
1349
  buildFragment(node, status, b, parentName, "t_before");
1350
1350
  status.fragmentStack.push({
@@ -1550,8 +1550,17 @@ function buildHeadNode(node, status, b) {
1550
1550
  });`);
1551
1551
  }
1552
1552
  function buildElementAttributes(node, varName, status, b) {
1553
+ const refAttribute = node.attributes.find((a) => a.name === "&ref");
1554
+ if (refAttribute) {
1555
+ let value = refAttribute.value;
1556
+ if (value != null && isFullyReactive(value)) {
1557
+ value = value.substring(1, value.length - 1);
1558
+ b.append(`${value} = ${varName};`);
1559
+ }
1560
+ }
1553
1561
  for (let { name, value } of node.attributes) {
1554
1562
  if (name === "self" && node.tagName === ":element") {
1563
+ } else if (name === "&ref") {
1555
1564
  } else if (name.startsWith("{") && name.endsWith("}")) {
1556
1565
  name = name.substring(1, name.length - 1);
1557
1566
  const propName = name.split(".").at(-1);
@@ -1562,9 +1571,7 @@ function buildElementAttributes(node, varName, status, b) {
1562
1571
  } else {
1563
1572
  value = `\`${trimQuotes(value).replaceAll("{", "${")}\``;
1564
1573
  }
1565
- if (name === "&ref") {
1566
- b.append(`${value} = ${varName};`);
1567
- } else if (name === "&group") {
1574
+ if (name === "&group") {
1568
1575
  buildBindGroupAttribute(node, varName, value, status, b);
1569
1576
  } else if (name === "&value" || name === "&checked") {
1570
1577
  buildBindAttribute(node, varName, name, value, status, b);