marko 6.0.0-next.3.67 → 6.0.0-next.3.69

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.
@@ -195,16 +195,12 @@ runtime.x = (op, id, node, start, placeholderCallback) => {
195
195
  placeholders[id] = {
196
196
  i: 1,
197
197
  c(end = runtime.l[id] || node) {
198
- while (end.parentNode !== start.parentNode) {
199
- end = end.parentNode;
200
- }
201
-
202
198
  for (
203
199
  ;
204
- end != nextSibling;
205
- (nextSibling = start.nextSibling).remove()
200
+ (nextSibling = end.previousSibling || start).remove(),
201
+ start != nextSibling;
206
202
  );
207
- replace(start, node);
203
+ replace(end, node);
208
204
  },
209
205
  };
210
206
  }
@@ -226,7 +222,7 @@ runtime.x = (op, id, node, start, placeholderCallback) => {
226
222
  }
227
223
  };
228
224
  })`
229
- ) : `(e=>{let i,t,r,l={},o=(e,i)=>{e.replaceWith(...i.childNodes),i.remove()};e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),e.j={},e.x=(d,n,a,c,p)=>{"#"==d?(l[n]=t).i++:a==r&&i(),"T"==a.tagName&&(n=a.getAttribute(e.i))&&((c=e.l["^"+n])&&(l[n]={i:1,c(i=e.l[n]||a){for(;i.parentNode!==c.parentNode;)i=i.parentNode;for(;i!=r;(r=c.nextSibling).remove());o(c,a)}}),r=a.nextSibling,t=l[n],i=()=>{c||o(e.l[n],a),--t.i||t.c()},(d=e.j[n])&&(p=t.c,t.c=()=>p()+d(e.r)))}})`;
225
+ ) : `(e=>{let i,l,t,r={},c=(e,i)=>{e.replaceWith(...i.childNodes),i.remove()};e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),e.j={},e.x=(d,o,n,a,g)=>{"#"==d?(r[o]=l).i++:n==t&&i(),"T"==n.tagName&&(o=n.getAttribute(e.i))&&((a=e.l["^"+o])&&(r[o]={i:1,c(i=e.l[o]||n){for(;(t=i.previousSibling||a).remove(),a!=t;);c(i,n)}}),t=n.nextSibling,l=r[o],i=()=>{a||c(e.l[o],n),--l.i||l.c()},(d=e.j[o])&&(g=l.c,l.c=()=>g()+d(e.r)))}})`;
230
226
 
231
227
  // src/html/serializer.ts
232
228
  var { hasOwnProperty } = {};
@@ -505,11 +501,7 @@ var Reference = class {
505
501
  };
506
502
  var DEBUG = /* @__PURE__ */ new WeakMap();
507
503
  function setDebugInfo(obj, file, loc, vars) {
508
- DEBUG.set(obj, {
509
- file,
510
- loc,
511
- vars
512
- });
504
+ DEBUG.set(obj, { file, loc, vars });
513
505
  }
514
506
  var Serializer = class {
515
507
  #state = new State();
@@ -568,10 +560,7 @@ function register(id, val, scope) {
568
560
  function getRegistered(val) {
569
561
  const registered = REGISTRY.get(val);
570
562
  if (registered) {
571
- return {
572
- id: registered.id,
573
- scope: registered.scope
574
- };
563
+ return { id: registered.id, scope: registered.scope };
575
564
  }
576
565
  }
577
566
  function writeRoot(state, root) {
@@ -741,7 +730,7 @@ function writeRegistered(state, val, parent, accessor, { access, scope, getter }
741
730
  return true;
742
731
  }
743
732
  if (scopeRef) {
744
- if (isCircular(parent, scopeRef)) {
733
+ if (parent && (state.assigned.has(scopeRef) || isCircular(parent, scopeRef))) {
745
734
  state.assigned.add(parent);
746
735
  state.assigned.add(fnRef);
747
736
  fnRef.init = access + "(" + ensureId(state, scopeRef) + ")";
@@ -1597,7 +1586,7 @@ function withContext(key, value, cb) {
1597
1586
  ctx[kPendingContexts]++;
1598
1587
  ctx[key] = value;
1599
1588
  try {
1600
- cb();
1589
+ return cb();
1601
1590
  } finally {
1602
1591
  ctx[kPendingContexts]--;
1603
1592
  ctx[key] = prev;
@@ -1658,23 +1647,33 @@ function hoist(scopeId, id) {
1658
1647
  function resumeClosestBranch(scopeId) {
1659
1648
  const branchId = $chunk.context?.[branchIdKey];
1660
1649
  if (branchId !== void 0 && branchId !== scopeId) {
1661
- writeScope(scopeId, {
1662
- ["#ClosestBranchId" /* ClosestBranchId */]: branchId
1663
- });
1650
+ writeScope(scopeId, { ["#ClosestBranchId" /* ClosestBranchId */]: branchId });
1664
1651
  }
1665
1652
  }
1666
1653
  var branchIdKey = Symbol();
1667
- function resumeForOf(list, cb, scopeId, accessor) {
1668
- forOf(list, (item, i) => {
1654
+ function withBranchId(branchId, cb) {
1655
+ return withContext(branchIdKey, branchId, cb);
1656
+ }
1657
+ function resumeForOf(list, cb, by, scopeId, accessor) {
1658
+ const loopScopes = /* @__PURE__ */ new Map();
1659
+ forOf(list, (item, index) => {
1669
1660
  const branchId = peekNextScopeId();
1670
1661
  $chunk.writeHTML(
1671
1662
  $chunk.boundary.state.mark(
1672
1663
  "[" /* BranchStart */,
1673
- branchId + (i ? " " : "")
1664
+ branchId + (index ? " " : "")
1674
1665
  )
1675
1666
  );
1676
- withContext(branchIdKey, branchId, () => cb(item, i));
1667
+ withBranchId(branchId, () => {
1668
+ cb(item, index);
1669
+ loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
1670
+ });
1677
1671
  });
1672
+ if (loopScopes.size) {
1673
+ writeScope(scopeId, {
1674
+ ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1675
+ });
1676
+ }
1678
1677
  $chunk.writeHTML(
1679
1678
  $chunk.boundary.state.mark(
1680
1679
  "]" /* BranchEnd */,
@@ -1682,13 +1681,22 @@ function resumeForOf(list, cb, scopeId, accessor) {
1682
1681
  )
1683
1682
  );
1684
1683
  }
1685
- function resumeSingleNodeForOf(list, cb, scopeId, accessor, onlyChildInParent) {
1684
+ function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, onlyChildInParent) {
1685
+ const loopScopes = /* @__PURE__ */ new Map();
1686
1686
  let branchIds = "";
1687
1687
  forOf(list, (item, index) => {
1688
1688
  const branchId = peekNextScopeId();
1689
1689
  branchIds = " " + branchId + branchIds;
1690
- withContext(branchIdKey, branchId, () => cb(item, index));
1690
+ withBranchId(branchId, () => {
1691
+ cb(item, index);
1692
+ loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
1693
+ });
1691
1694
  });
1695
+ if (loopScopes.size) {
1696
+ writeScope(scopeId, {
1697
+ ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1698
+ });
1699
+ }
1692
1700
  $chunk.writeHTML(
1693
1701
  $chunk.boundary.state.mark(
1694
1702
  onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
@@ -1696,7 +1704,17 @@ function resumeSingleNodeForOf(list, cb, scopeId, accessor, onlyChildInParent) {
1696
1704
  )
1697
1705
  );
1698
1706
  }
1699
- function resumeForIn(obj, cb, scopeId, accessor) {
1707
+ function forOfBy(by, item, index) {
1708
+ if (by) {
1709
+ if (typeof by === "string") {
1710
+ return item[by];
1711
+ }
1712
+ return by(item, index);
1713
+ }
1714
+ return index;
1715
+ }
1716
+ function resumeForIn(obj, cb, by, scopeId, accessor) {
1717
+ const loopScopes = /* @__PURE__ */ new Map();
1700
1718
  let sep = "";
1701
1719
  forIn(obj, (key, value) => {
1702
1720
  const branchId = peekNextScopeId();
@@ -1704,8 +1722,16 @@ function resumeForIn(obj, cb, scopeId, accessor) {
1704
1722
  $chunk.boundary.state.mark("[" /* BranchStart */, branchId + sep)
1705
1723
  );
1706
1724
  sep = " ";
1707
- withContext(branchIdKey, branchId, () => cb(key, value));
1725
+ withBranchId(branchId, () => {
1726
+ cb(key, value);
1727
+ loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
1728
+ });
1708
1729
  });
1730
+ if (loopScopes.size) {
1731
+ writeScope(scopeId, {
1732
+ ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1733
+ });
1734
+ }
1709
1735
  $chunk.writeHTML(
1710
1736
  $chunk.boundary.state.mark(
1711
1737
  "]" /* BranchEnd */,
@@ -1713,13 +1739,22 @@ function resumeForIn(obj, cb, scopeId, accessor) {
1713
1739
  )
1714
1740
  );
1715
1741
  }
1716
- function resumeSingleNodeForIn(obj, cb, scopeId, accessor, onlyChild) {
1742
+ function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, onlyChild) {
1743
+ const loopScopes = /* @__PURE__ */ new Map();
1717
1744
  let branchIds = "";
1718
1745
  forIn(obj, (key, value) => {
1719
1746
  const branchId = peekNextScopeId();
1720
1747
  branchIds = " " + branchId + branchIds;
1721
- withContext(branchIdKey, branchId, () => cb(key, value));
1748
+ withBranchId(branchId, () => {
1749
+ cb(key, value);
1750
+ loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
1751
+ });
1722
1752
  });
1753
+ if (loopScopes.size) {
1754
+ writeScope(scopeId, {
1755
+ ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1756
+ });
1757
+ }
1723
1758
  $chunk.writeHTML(
1724
1759
  $chunk.boundary.state.mark(
1725
1760
  onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
@@ -1727,7 +1762,14 @@ function resumeSingleNodeForIn(obj, cb, scopeId, accessor, onlyChild) {
1727
1762
  )
1728
1763
  );
1729
1764
  }
1730
- function resumeForTo(to, from, step, cb, scopeId, accessor) {
1765
+ function forInBy(by, name, value) {
1766
+ if (by) {
1767
+ return by(name, value);
1768
+ }
1769
+ return name;
1770
+ }
1771
+ function resumeForTo(to, from, step, cb, by, scopeId, accessor) {
1772
+ const loopScopes = /* @__PURE__ */ new Map();
1731
1773
  let sep = "";
1732
1774
  forTo(to, from, step, (index) => {
1733
1775
  const branchId = peekNextScopeId();
@@ -1735,8 +1777,16 @@ function resumeForTo(to, from, step, cb, scopeId, accessor) {
1735
1777
  $chunk.boundary.state.mark("[" /* BranchStart */, branchId + sep)
1736
1778
  );
1737
1779
  sep = " ";
1738
- withContext(branchIdKey, branchId, () => cb(index));
1780
+ withBranchId(branchId, () => {
1781
+ cb(index);
1782
+ loopScopes.set(forToBy(by, index), writeScope(branchId, {}));
1783
+ });
1739
1784
  });
1785
+ if (loopScopes.size) {
1786
+ writeScope(scopeId, {
1787
+ ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1788
+ });
1789
+ }
1740
1790
  $chunk.writeHTML(
1741
1791
  $chunk.boundary.state.mark(
1742
1792
  "]" /* BranchEnd */,
@@ -1744,13 +1794,22 @@ function resumeForTo(to, from, step, cb, scopeId, accessor) {
1744
1794
  )
1745
1795
  );
1746
1796
  }
1747
- function resumeSingleNodeForTo(to, from, step, cb, scopeId, accessor, onlyChild) {
1797
+ function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, onlyChild) {
1798
+ const loopScopes = /* @__PURE__ */ new Map();
1748
1799
  let branchIds = "";
1749
1800
  forTo(to, from, step, (index) => {
1750
1801
  const branchId = peekNextScopeId();
1751
1802
  branchIds = " " + branchId + branchIds;
1752
- withContext(branchIdKey, branchId, () => cb(index));
1803
+ withBranchId(branchId, () => {
1804
+ cb(index);
1805
+ loopScopes.set(forToBy(by, index), writeScope(branchId, {}));
1806
+ });
1753
1807
  });
1808
+ if (loopScopes.size) {
1809
+ writeScope(scopeId, {
1810
+ ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1811
+ });
1812
+ }
1754
1813
  $chunk.writeHTML(
1755
1814
  $chunk.boundary.state.mark(
1756
1815
  onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
@@ -1758,40 +1817,57 @@ function resumeSingleNodeForTo(to, from, step, cb, scopeId, accessor, onlyChild)
1758
1817
  )
1759
1818
  );
1760
1819
  }
1761
- function resumeConditional(cb, scopeId, accessor) {
1820
+ function forToBy(by, index) {
1821
+ if (by) {
1822
+ return by(index);
1823
+ }
1824
+ return index;
1825
+ }
1826
+ function resumeConditional(cb, scopeId, accessor, dynamic) {
1762
1827
  const branchId = peekNextScopeId();
1763
- $chunk.writeHTML(
1764
- $chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
1765
- );
1766
- withContext(branchIdKey, branchId, cb);
1767
- const rendered = peekNextScopeId() !== branchId;
1768
- if (rendered) {
1769
- writeScope(branchId, {});
1828
+ if (dynamic) {
1829
+ $chunk.writeHTML(
1830
+ $chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
1831
+ );
1832
+ }
1833
+ const branchIndex = withBranchId(branchId, cb);
1834
+ if (branchIndex !== void 0) {
1835
+ writeScope(scopeId, {
1836
+ ["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: dynamic ? branchIndex : void 0,
1837
+ ["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
1838
+ });
1770
1839
  } else {
1771
1840
  nextScopeId();
1772
1841
  }
1773
- $chunk.writeHTML(
1774
- $chunk.boundary.state.mark(
1775
- "]" /* BranchEnd */,
1776
- scopeId + " " + accessor
1777
- )
1778
- );
1842
+ if (dynamic) {
1843
+ $chunk.writeHTML(
1844
+ $chunk.boundary.state.mark(
1845
+ "]" /* BranchEnd */,
1846
+ scopeId + " " + accessor
1847
+ )
1848
+ );
1849
+ }
1779
1850
  }
1780
- function resumeSingleNodeConditional(cb, scopeId, accessor, onlyChild) {
1851
+ function resumeSingleNodeConditional(cb, scopeId, accessor, dynamic, onlyChild) {
1781
1852
  const branchId = peekNextScopeId();
1782
- withContext(branchIdKey, branchId, cb);
1783
- const rendered = peekNextScopeId() !== branchId;
1853
+ const branchIndex = withBranchId(branchId, cb);
1854
+ const rendered = branchIndex !== void 0;
1784
1855
  if (rendered) {
1785
- writeScope(branchId, {});
1856
+ writeScope(scopeId, {
1857
+ ["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: dynamic ? branchIndex : void 0,
1858
+ ["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
1859
+ });
1786
1860
  } else {
1787
1861
  nextScopeId();
1788
1862
  }
1789
- $chunk.writeHTML(
1790
- $chunk.boundary.state.mark(
1791
- onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1792
- scopeId + " " + accessor + (rendered ? " " + branchId : "")
1793
- )
1794
- );
1863
+ if (dynamic) {
1864
+ $chunk.writeHTML(
1865
+ $chunk.boundary.state.mark(
1866
+ onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1867
+ scopeId + " " + accessor + (rendered ? " " + branchId : "")
1868
+ )
1869
+ );
1870
+ }
1795
1871
  }
1796
1872
  var writeScope = (scopeId, partialScope) => {
1797
1873
  const { state } = $chunk.boundary;
@@ -2257,8 +2333,8 @@ function prepareChunk(chunk) {
2257
2333
  let cur = reorderedChunk;
2258
2334
  reorderedChunk.reorderId = null;
2259
2335
  for (; ; ) {
2260
- const { next } = cur;
2261
2336
  cur.flushPlaceholder();
2337
+ const { next } = cur;
2262
2338
  cur.consumed = true;
2263
2339
  reorderHTML += cur.html;
2264
2340
  reorderEffects = concatEffects(reorderEffects, cur.effects);
@@ -2644,117 +2720,97 @@ var DEFAULT_RENDER_ID = "_";
2644
2720
 
2645
2721
  // src/html/dynamic-tag.ts
2646
2722
  var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
2647
- function dynamicTagId(tagName) {
2648
- const normalizedRenderer = normalizeDynamicRenderer(tagName);
2649
- return normalizedRenderer?.___id || normalizedRenderer;
2650
- }
2651
- var dynamicTagInput = (scopeId, accessor, tag, input, content) => {
2652
- if (!tag && !content) {
2653
- nextScopeId();
2654
- return;
2655
- }
2656
- if (!tag) {
2657
- resumeConditional(content, scopeId, accessor);
2658
- return;
2723
+ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, resume) => {
2724
+ const renderer = normalizeDynamicRenderer(tag);
2725
+ if (true) {
2726
+ if (renderer && typeof renderer !== "function" && typeof renderer !== "string") {
2727
+ throw new Error(`Invalid renderer passed for dynamic tag: ${renderer}`);
2728
+ }
2659
2729
  }
2660
- if (typeof tag === "string") {
2661
- resumeSingleNodeConditional(
2662
- () => {
2663
- nextScopeId();
2664
- write(`<${tag}${attrs(input, accessor, scopeId, tag)}>`);
2665
- if (!voidElementsReg.test(tag)) {
2666
- if (tag === "textarea") {
2667
- if (content) {
2668
- throw new Error(
2669
- "A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead."
2670
- );
2671
- }
2672
- write(
2673
- controllable_textarea_value(
2674
- scopeId,
2675
- accessor,
2676
- input.value,
2677
- input.valueChange
2678
- )
2730
+ const chunk = getChunk();
2731
+ const branchId = peekNextScopeId();
2732
+ let result;
2733
+ if (typeof renderer === "string") {
2734
+ const input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
2735
+ nextScopeId();
2736
+ write(`<${renderer}${attrs(input, accessor, scopeId, renderer)}>`);
2737
+ if (!voidElementsReg.test(renderer)) {
2738
+ withBranchId(branchId, () => {
2739
+ if (renderer === "textarea") {
2740
+ if (content) {
2741
+ throw new Error(
2742
+ "A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead."
2679
2743
  );
2680
- } else if (content) {
2681
- if (tag === "select" && ("value" in input || "valueChange" in input)) {
2682
- controllable_select_value(
2683
- scopeId,
2684
- accessor,
2685
- input.value,
2686
- input.valueChange,
2687
- content
2688
- );
2689
- } else {
2690
- content();
2691
- }
2692
2744
  }
2693
- write(`</${tag}>`);
2745
+ write(
2746
+ controllable_textarea_value(
2747
+ scopeId,
2748
+ accessor,
2749
+ input.value,
2750
+ input.valueChange
2751
+ )
2752
+ );
2694
2753
  } else if (content) {
2695
- throw new Error(`Body content is not supported for a "${tag}" tag.`);
2754
+ if (renderer === "select" && ("value" in input || "valueChange" in input)) {
2755
+ controllable_select_value(
2756
+ scopeId,
2757
+ accessor,
2758
+ input.value,
2759
+ input.valueChange,
2760
+ content
2761
+ );
2762
+ } else {
2763
+ content();
2764
+ }
2696
2765
  }
2697
- },
2698
- scopeId,
2699
- accessor
2700
- );
2701
- return;
2702
- }
2703
- const renderer = normalizeDynamicRenderer(
2704
- tag
2705
- );
2706
- if (true) {
2707
- if (typeof renderer !== "function") {
2708
- throw new Error(`Invalid renderer passed for dynamic tag: ${tag}`);
2766
+ });
2767
+ write(`</${renderer}>`);
2768
+ } else if (content) {
2769
+ throw new Error(`Body content is not supported for a "${renderer}" tag.`);
2770
+ }
2771
+ if (resume) {
2772
+ chunk.writeHTML(
2773
+ chunk.boundary.state.mark(
2774
+ "|" /* BranchSingleNode */,
2775
+ scopeId + " " + accessor + " " + branchId
2776
+ )
2777
+ );
2709
2778
  }
2710
- }
2711
- let result;
2712
- resumeConditional(
2713
- () => {
2714
- result = renderer(content ? { ...input, content } : input);
2715
- },
2716
- scopeId,
2717
- accessor
2718
- );
2719
- return result;
2720
- };
2721
- var dynamicTagArgs = (scopeId, accessor, tag, args) => {
2722
- if (!tag) {
2723
- nextScopeId();
2724
- return;
2725
- }
2726
- if (typeof tag === "string") {
2727
- resumeSingleNodeConditional(
2728
- () => {
2729
- nextScopeId();
2730
- write(
2731
- `<${tag}${attrs(args[0], accessor, scopeId, tag)}>`
2779
+ } else {
2780
+ if (resume) {
2781
+ chunk.writeHTML(
2782
+ chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
2783
+ );
2784
+ }
2785
+ result = withBranchId(branchId, () => {
2786
+ if (renderer) {
2787
+ return inputIsArgs ? renderer(...inputOrArgs) : renderer(
2788
+ content ? { ...inputOrArgs, content } : inputOrArgs
2732
2789
  );
2733
- if (!voidElementsReg.test(tag)) {
2734
- write(`</${tag}>`);
2735
- }
2736
- },
2737
- scopeId,
2738
- accessor
2739
- );
2740
- return;
2790
+ } else if (content) {
2791
+ return content();
2792
+ }
2793
+ });
2794
+ if (resume) {
2795
+ chunk.writeHTML(
2796
+ chunk.boundary.state.mark(
2797
+ "]" /* BranchEnd */,
2798
+ scopeId + " " + accessor
2799
+ )
2800
+ );
2801
+ }
2741
2802
  }
2742
- const renderer = normalizeDynamicRenderer(
2743
- tag
2744
- );
2745
- if (true) {
2746
- if (typeof renderer !== "function") {
2747
- throw new Error(`Invalid renderer passed for dynamic tag: ${tag}`);
2803
+ const rendered = peekNextScopeId() !== branchId;
2804
+ if (rendered) {
2805
+ if (resume) {
2806
+ writeScope(scopeId, {
2807
+ ["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {}),
2808
+ ["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: renderer?.___id || renderer
2809
+ });
2748
2810
  }
2811
+ } else {
2812
+ nextScopeId();
2749
2813
  }
2750
- let result;
2751
- resumeConditional(
2752
- () => {
2753
- result = renderer(...args);
2754
- },
2755
- scopeId,
2756
- accessor
2757
- );
2758
2814
  return result;
2759
2815
  };
2760
2816
  function createContent(id, fn) {
@@ -2765,19 +2821,19 @@ function registerContent(id, fn, scopeId) {
2765
2821
  return register2(createContent(id, fn), id, scopeId);
2766
2822
  }
2767
2823
  function patchDynamicTag(patch) {
2768
- dynamicTagInput = /* @__PURE__ */ ((originalDynamicTagInput) => (scopeId, accessor, tag, input, content) => originalDynamicTagInput(
2769
- scopeId,
2770
- accessor,
2771
- patch(scopeId, accessor, tag),
2772
- input,
2773
- content
2774
- ))(dynamicTagInput);
2775
- dynamicTagArgs = /* @__PURE__ */ ((originalDynamicTagArgs) => (scopeId, accessor, tag, args) => originalDynamicTagArgs(
2776
- scopeId,
2777
- accessor,
2778
- patch(scopeId, accessor, tag),
2779
- args
2780
- ))(dynamicTagArgs);
2824
+ dynamicTag = /* @__PURE__ */ ((originalDynamicTag) => (scopeId, accessor, tag, input, content, inputIsArgs, resume) => {
2825
+ const patched = patch(scopeId, accessor, tag);
2826
+ patched.___id = tag;
2827
+ return originalDynamicTag(
2828
+ scopeId,
2829
+ accessor,
2830
+ patched,
2831
+ input,
2832
+ content,
2833
+ inputIsArgs,
2834
+ resume
2835
+ );
2836
+ })(dynamicTag);
2781
2837
  }
2782
2838
 
2783
2839
  // src/html/compat.ts
@@ -2877,7 +2933,7 @@ var compat = {
2877
2933
  };
2878
2934
 
2879
2935
  // src/html/for.ts
2880
- function forOfBy(by, item, index) {
2936
+ function forOfBy2(by, item, index) {
2881
2937
  if (by) {
2882
2938
  if (typeof by === "string") {
2883
2939
  return item[by];
@@ -2886,13 +2942,13 @@ function forOfBy(by, item, index) {
2886
2942
  }
2887
2943
  return index;
2888
2944
  }
2889
- function forInBy(by, name, value) {
2945
+ function forInBy2(by, name, value) {
2890
2946
  if (by) {
2891
2947
  return by(name, value);
2892
2948
  }
2893
2949
  return name;
2894
2950
  }
2895
- function forToBy(by, index) {
2951
+ function forToBy2(by, index) {
2896
2952
  if (by) {
2897
2953
  return by(index);
2898
2954
  }
@@ -3137,19 +3193,17 @@ export {
3137
3193
  controllable_textarea_value,
3138
3194
  createContent,
3139
3195
  createTemplate,
3140
- dynamicTagArgs,
3141
- dynamicTagId,
3142
- dynamicTagInput,
3196
+ dynamicTag,
3143
3197
  ensureScopeWithId,
3144
3198
  escapeScript,
3145
3199
  escapeStyle,
3146
3200
  escapeXML,
3147
3201
  forIn,
3148
- forInBy,
3202
+ forInBy2 as forInBy,
3149
3203
  forOf,
3150
- forOfBy,
3204
+ forOfBy2 as forOfBy,
3151
3205
  forTo,
3152
- forToBy,
3206
+ forToBy2 as forToBy,
3153
3207
  fork,
3154
3208
  getScopeById,
3155
3209
  hoist,
package/dist/dom.js CHANGED
@@ -222,7 +222,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
222
222
  visits.length = 0;
223
223
  let branchEnd = (branchId, reference) => {
224
224
  let branch = scopeLookup[branchId] ||= {}, endNode = reference;
225
- for (; visitNodes.has(endNode = endNode.previousSibling); ) ;
225
+ for (; endNode.previousSibling !== branch.h && visitNodes.has(endNode = endNode.previousSibling); ) ;
226
226
  return endNode === lastEndNode && (endNode = reference.parentNode.insertBefore(
227
227
  new Text(),
228
228
  reference
@@ -1112,15 +1112,11 @@ function awaitTag(nodeAccessor, renderer) {
1112
1112
  })
1113
1113
  ), tryWithPlaceholder && !--tryWithPlaceholder.q)) {
1114
1114
  let placeholderBranch = tryWithPlaceholder.c;
1115
- tryWithPlaceholder.c = void 0, placeholderBranch ? (insertBranchBefore(
1115
+ tryWithPlaceholder.c = void 0, placeholderBranch && (insertBranchBefore(
1116
1116
  tryWithPlaceholder,
1117
1117
  placeholderBranch.h.parentNode,
1118
1118
  placeholderBranch.h
1119
- ), removeAndDestroyBranch(placeholderBranch)) : insertBranchBefore(
1120
- tryWithPlaceholder,
1121
- referenceNode.parentNode,
1122
- referenceNode
1123
- ), tryWithPlaceholder.H && runEffects(tryWithPlaceholder.H, !0);
1119
+ ), removeAndDestroyBranch(placeholderBranch)), tryWithPlaceholder.H && runEffects(tryWithPlaceholder.H, !0);
1124
1120
  }
1125
1121
  }).catch((error) => {
1126
1122
  renderCatch(scope, error, !0);