tutuca 0.9.4 → 0.9.5

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.
@@ -1857,6 +1857,14 @@ class Pair {
1857
1857
  v = v.tail;
1858
1858
  }
1859
1859
  }
1860
+ lookupNode(pred) {
1861
+ for (const node of this) {
1862
+ if (pred(node)) {
1863
+ return node;
1864
+ }
1865
+ }
1866
+ return null;
1867
+ }
1860
1868
  }
1861
1869
 
1862
1870
  class BindFrame {
@@ -1945,7 +1953,7 @@ class Stack {
1945
1953
  return this.ctx.lookupName(name);
1946
1954
  }
1947
1955
  lookupComputed(name) {
1948
- return this.comps.lookupComputed(this.it, name);
1956
+ return this.comps.lookupComputed(this.binds.lookupNode((v) => v.isFrame)?.it, name);
1949
1957
  }
1950
1958
  getInputHandler(name) {
1951
1959
  return this.comps.getInputHandlerFor(this.it, name);
@@ -2107,6 +2115,7 @@ class Transaction {
2107
2115
  }
2108
2116
  }
2109
2117
  var isMac2 = (globalThis.navigator?.userAgent ?? "").toLowerCase().includes("mac");
2118
+ var toNullIfNaN = (v) => Number.isNaN(v) ? null : v;
2110
2119
  function getValue(e) {
2111
2120
  return e.target.type === "checkbox" ? e.target.checked : (e instanceof CustomEvent ? e.detail : e.target.value) ?? null;
2112
2121
  }
@@ -2138,6 +2147,10 @@ class InputEvent extends Transaction {
2138
2147
  switch (name) {
2139
2148
  case "value":
2140
2149
  return getValue(e);
2150
+ case "valueAsInt":
2151
+ return toNullIfNaN(parseInt(getValue(e), 10));
2152
+ case "valueAsFloat":
2153
+ return toNullIfNaN(parseFloat(getValue(e)));
2141
2154
  case "target":
2142
2155
  return e.target;
2143
2156
  case "event":
@@ -2496,7 +2509,7 @@ class ParseCtxClassSetCollector extends ParseContext {
2496
2509
  const { value, thenVal, elseVal } = attr;
2497
2510
  if (thenVal !== undefined) {
2498
2511
  this._addClasses(thenVal.value);
2499
- if (elseVal) {
2512
+ if (typeof elseVal?.value === "string") {
2500
2513
  this._addClasses(elseVal.value);
2501
2514
  }
2502
2515
  } else if (typeof value?.value === "string") {
@@ -7922,6 +7935,8 @@ function checkEventModifiers(lx, view) {
7922
7935
  function isKnownHandlerName(name) {
7923
7936
  switch (name) {
7924
7937
  case "value":
7938
+ case "valueAsInt":
7939
+ case "valueAsFloat":
7925
7940
  case "target":
7926
7941
  case "event":
7927
7942
  case "isAlt":