tutuca 0.9.4 → 0.9.6

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.
@@ -369,7 +369,7 @@ class ValParser {
369
369
  this.allowFieldOnly();
370
370
  this.okName = true;
371
371
  const val = this.parse(s, px);
372
- return val.toRawFieldVal ? val.toRawFieldVal() : new HandlerClass(val.name);
372
+ return val && (val.toRawFieldVal ? val.toRawFieldVal() : new HandlerClass(val.name));
373
373
  }
374
374
  parseHandlerName(s, px) {
375
375
  return this._parseHandler(s, px, InputHandlerNameVal);
@@ -721,7 +721,7 @@ class AttrParser {
721
721
  this.pushWrapper("push-view", s, vp.parseText(s, this.px));
722
722
  return;
723
723
  case "text":
724
- this.textChild = vp.parseText(s, this.px) ?? vp.const("");
724
+ this.textChild = vp.parseText(s, this.px);
725
725
  return;
726
726
  case "show":
727
727
  this.pushWrapper("show", s, vp.parseCondValue(s, this.px));
@@ -1079,8 +1079,10 @@ class ANode extends BaseNode {
1079
1079
  switch (name) {
1080
1080
  case "slot":
1081
1081
  return new SlotNode(null, vp.const(value), maybeFragment(childs));
1082
- case "text":
1083
- return new RenderTextNode(null, vp.parseText(value, px) ?? vp.const(""));
1082
+ case "text": {
1083
+ const v = vp.parseText(value, px);
1084
+ return v !== null ? new RenderTextNode(null, v) : null;
1085
+ }
1084
1086
  case "render":
1085
1087
  return px.addNodeIf(RenderNode, vp.parseRender(value, px), as);
1086
1088
  case "render-it":
@@ -1124,8 +1126,8 @@ function wrap(node, px, wrappers) {
1124
1126
  }
1125
1127
  function makeWrapperNode(data, px) {
1126
1128
  const Cls = WRAPPER_NODES[data.name];
1127
- const node = Cls.register ? px.addNodeIf(Cls, data.val) : new Cls(null, data.val);
1128
- if (data.name === "each") {
1129
+ const node = Cls.register ? px.addNodeIf(Cls, data.val) : data.val && new Cls(null, data.val);
1130
+ if (node !== null && data.name === "each") {
1129
1131
  node.iterInfo.enrichWithVal = data.enrichWithVal ?? null;
1130
1132
  node.iterInfo.whenVal = data.whenVal ?? null;
1131
1133
  node.iterInfo.loopWithVal = data.loopWithVal ?? null;
@@ -1945,7 +1947,8 @@ class Stack {
1945
1947
  return this.ctx.lookupName(name);
1946
1948
  }
1947
1949
  lookupComputed(name) {
1948
- return this.comps.lookupComputed(this.it, name);
1950
+ const node = this.binds.head.isFrame ? this.binds.head : this.binds.tail.head;
1951
+ return this.comps.lookupComputed(node.it, name);
1949
1952
  }
1950
1953
  getInputHandler(name) {
1951
1954
  return this.comps.getInputHandlerFor(this.it, name);
@@ -2107,6 +2110,7 @@ class Transaction {
2107
2110
  }
2108
2111
  }
2109
2112
  var isMac2 = (globalThis.navigator?.userAgent ?? "").toLowerCase().includes("mac");
2113
+ var toNullIfNaN = (v) => Number.isNaN(v) ? null : v;
2110
2114
  function getValue(e) {
2111
2115
  return e.target.type === "checkbox" ? e.target.checked : (e instanceof CustomEvent ? e.detail : e.target.value) ?? null;
2112
2116
  }
@@ -2138,6 +2142,10 @@ class InputEvent extends Transaction {
2138
2142
  switch (name) {
2139
2143
  case "value":
2140
2144
  return getValue(e);
2145
+ case "valueAsInt":
2146
+ return toNullIfNaN(parseInt(getValue(e), 10));
2147
+ case "valueAsFloat":
2148
+ return toNullIfNaN(parseFloat(getValue(e)));
2141
2149
  case "target":
2142
2150
  return e.target;
2143
2151
  case "event":
@@ -2496,11 +2504,17 @@ class ParseCtxClassSetCollector extends ParseContext {
2496
2504
  const { value, thenVal, elseVal } = attr;
2497
2505
  if (thenVal !== undefined) {
2498
2506
  this._addClasses(thenVal.value);
2499
- if (elseVal) {
2507
+ if (typeof elseVal?.value === "string") {
2500
2508
  this._addClasses(elseVal.value);
2501
2509
  }
2502
2510
  } else if (typeof value?.value === "string") {
2503
2511
  this._addClasses(value.value);
2512
+ } else if (value?.vals !== undefined) {
2513
+ for (const val of value.vals) {
2514
+ if (val instanceof ConstVal && val.value !== "") {
2515
+ this._addClasses(val.value);
2516
+ }
2517
+ }
2504
2518
  }
2505
2519
  }
2506
2520
  } else {
@@ -7922,6 +7936,8 @@ function checkEventModifiers(lx, view) {
7922
7936
  function isKnownHandlerName(name) {
7923
7937
  switch (name) {
7924
7938
  case "value":
7939
+ case "valueAsInt":
7940
+ case "valueAsFloat":
7925
7941
  case "target":
7926
7942
  case "event":
7927
7943
  case "isAlt":