tutuca 0.9.5 → 0.9.7

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;
@@ -1857,14 +1859,6 @@ class Pair {
1857
1859
  v = v.tail;
1858
1860
  }
1859
1861
  }
1860
- lookupNode(pred) {
1861
- for (const node of this) {
1862
- if (pred(node)) {
1863
- return node;
1864
- }
1865
- }
1866
- return null;
1867
- }
1868
1862
  }
1869
1863
 
1870
1864
  class BindFrame {
@@ -1953,7 +1947,8 @@ class Stack {
1953
1947
  return this.ctx.lookupName(name);
1954
1948
  }
1955
1949
  lookupComputed(name) {
1956
- return this.comps.lookupComputed(this.binds.lookupNode((v) => v.isFrame)?.it, name);
1950
+ const node = this.binds.head.isFrame ? this.binds.head : this.binds.tail.head;
1951
+ return this.comps.lookupComputed(node.it, name);
1957
1952
  }
1958
1953
  getInputHandler(name) {
1959
1954
  return this.comps.getInputHandlerFor(this.it, name);
@@ -2508,12 +2503,10 @@ class ParseCtxClassSetCollector extends ParseContext {
2508
2503
  }
2509
2504
  const { value, thenVal, elseVal } = attr;
2510
2505
  if (thenVal !== undefined) {
2511
- this._addClasses(thenVal.value);
2512
- if (typeof elseVal?.value === "string") {
2513
- this._addClasses(elseVal.value);
2514
- }
2515
- } else if (typeof value?.value === "string") {
2516
- this._addClasses(value.value);
2506
+ this._maybeAddVal(thenVal);
2507
+ this._maybeAddVal(elseVal);
2508
+ } else {
2509
+ this._maybeAddVal(value);
2517
2510
  }
2518
2511
  }
2519
2512
  } else {
@@ -2523,6 +2516,22 @@ class ParseCtxClassSetCollector extends ParseContext {
2523
2516
  }
2524
2517
  }
2525
2518
  }
2519
+ _maybeAddVal(value) {
2520
+ if (!this._maybeAddStrTpl(value) && typeof value?.value === "string") {
2521
+ this._addClasses(value.value);
2522
+ }
2523
+ }
2524
+ _maybeAddStrTpl(value) {
2525
+ if (value?.vals !== undefined) {
2526
+ for (const val of value.vals) {
2527
+ if (val instanceof ConstVal && val.value !== "") {
2528
+ this._addClasses(val.value);
2529
+ }
2530
+ }
2531
+ return true;
2532
+ }
2533
+ return false;
2534
+ }
2526
2535
  }
2527
2536
 
2528
2537
  // deps/immutable.js