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.
@@ -35,19 +35,17 @@ __export(html_exports, {
35
35
  controllable_textarea_value: () => controllable_textarea_value,
36
36
  createContent: () => createContent,
37
37
  createTemplate: () => createTemplate,
38
- dynamicTagArgs: () => dynamicTagArgs,
39
- dynamicTagId: () => dynamicTagId,
40
- dynamicTagInput: () => dynamicTagInput,
38
+ dynamicTag: () => dynamicTag,
41
39
  ensureScopeWithId: () => ensureScopeWithId,
42
40
  escapeScript: () => escapeScript,
43
41
  escapeStyle: () => escapeStyle,
44
42
  escapeXML: () => escapeXML,
45
43
  forIn: () => forIn,
46
- forInBy: () => forInBy,
44
+ forInBy: () => forInBy2,
47
45
  forOf: () => forOf,
48
- forOfBy: () => forOfBy,
46
+ forOfBy: () => forOfBy2,
49
47
  forTo: () => forTo,
50
- forToBy: () => forToBy,
48
+ forToBy: () => forToBy2,
51
49
  fork: () => fork,
52
50
  getScopeById: () => getScopeById,
53
51
  hoist: () => hoist,
@@ -279,16 +277,12 @@ runtime.x = (op, id, node, start, placeholderCallback) => {
279
277
  placeholders[id] = {
280
278
  i: 1,
281
279
  c(end = runtime.l[id] || node) {
282
- while (end.parentNode !== start.parentNode) {
283
- end = end.parentNode;
284
- }
285
-
286
280
  for (
287
281
  ;
288
- end != nextSibling;
289
- (nextSibling = start.nextSibling).remove()
282
+ (nextSibling = end.previousSibling || start).remove(),
283
+ start != nextSibling;
290
284
  );
291
- replace(start, node);
285
+ replace(end, node);
292
286
  },
293
287
  };
294
288
  }
@@ -310,7 +304,7 @@ runtime.x = (op, id, node, start, placeholderCallback) => {
310
304
  }
311
305
  };
312
306
  })`
313
- ) : `(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)))}})`;
307
+ ) : `(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)))}})`;
314
308
 
315
309
  // src/html/serializer.ts
316
310
  var { hasOwnProperty } = {};
@@ -589,11 +583,7 @@ var Reference = class {
589
583
  };
590
584
  var DEBUG = /* @__PURE__ */ new WeakMap();
591
585
  function setDebugInfo(obj, file, loc, vars) {
592
- DEBUG.set(obj, {
593
- file,
594
- loc,
595
- vars
596
- });
586
+ DEBUG.set(obj, { file, loc, vars });
597
587
  }
598
588
  var Serializer = class {
599
589
  #state = new State();
@@ -652,10 +642,7 @@ function register(id, val, scope) {
652
642
  function getRegistered(val) {
653
643
  const registered = REGISTRY.get(val);
654
644
  if (registered) {
655
- return {
656
- id: registered.id,
657
- scope: registered.scope
658
- };
645
+ return { id: registered.id, scope: registered.scope };
659
646
  }
660
647
  }
661
648
  function writeRoot(state, root) {
@@ -825,7 +812,7 @@ function writeRegistered(state, val, parent, accessor, { access, scope, getter }
825
812
  return true;
826
813
  }
827
814
  if (scopeRef) {
828
- if (isCircular(parent, scopeRef)) {
815
+ if (parent && (state.assigned.has(scopeRef) || isCircular(parent, scopeRef))) {
829
816
  state.assigned.add(parent);
830
817
  state.assigned.add(fnRef);
831
818
  fnRef.init = access + "(" + ensureId(state, scopeRef) + ")";
@@ -1681,7 +1668,7 @@ function withContext(key, value, cb) {
1681
1668
  ctx[kPendingContexts]++;
1682
1669
  ctx[key] = value;
1683
1670
  try {
1684
- cb();
1671
+ return cb();
1685
1672
  } finally {
1686
1673
  ctx[kPendingContexts]--;
1687
1674
  ctx[key] = prev;
@@ -1742,23 +1729,33 @@ function hoist(scopeId, id) {
1742
1729
  function resumeClosestBranch(scopeId) {
1743
1730
  const branchId = $chunk.context?.[branchIdKey];
1744
1731
  if (branchId !== void 0 && branchId !== scopeId) {
1745
- writeScope(scopeId, {
1746
- ["#ClosestBranchId" /* ClosestBranchId */]: branchId
1747
- });
1732
+ writeScope(scopeId, { ["#ClosestBranchId" /* ClosestBranchId */]: branchId });
1748
1733
  }
1749
1734
  }
1750
1735
  var branchIdKey = Symbol();
1751
- function resumeForOf(list, cb, scopeId, accessor) {
1752
- forOf(list, (item, i) => {
1736
+ function withBranchId(branchId, cb) {
1737
+ return withContext(branchIdKey, branchId, cb);
1738
+ }
1739
+ function resumeForOf(list, cb, by, scopeId, accessor) {
1740
+ const loopScopes = /* @__PURE__ */ new Map();
1741
+ forOf(list, (item, index) => {
1753
1742
  const branchId = peekNextScopeId();
1754
1743
  $chunk.writeHTML(
1755
1744
  $chunk.boundary.state.mark(
1756
1745
  "[" /* BranchStart */,
1757
- branchId + (i ? " " : "")
1746
+ branchId + (index ? " " : "")
1758
1747
  )
1759
1748
  );
1760
- withContext(branchIdKey, branchId, () => cb(item, i));
1749
+ withBranchId(branchId, () => {
1750
+ cb(item, index);
1751
+ loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
1752
+ });
1761
1753
  });
1754
+ if (loopScopes.size) {
1755
+ writeScope(scopeId, {
1756
+ ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1757
+ });
1758
+ }
1762
1759
  $chunk.writeHTML(
1763
1760
  $chunk.boundary.state.mark(
1764
1761
  "]" /* BranchEnd */,
@@ -1766,13 +1763,22 @@ function resumeForOf(list, cb, scopeId, accessor) {
1766
1763
  )
1767
1764
  );
1768
1765
  }
1769
- function resumeSingleNodeForOf(list, cb, scopeId, accessor, onlyChildInParent) {
1766
+ function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, onlyChildInParent) {
1767
+ const loopScopes = /* @__PURE__ */ new Map();
1770
1768
  let branchIds = "";
1771
1769
  forOf(list, (item, index) => {
1772
1770
  const branchId = peekNextScopeId();
1773
1771
  branchIds = " " + branchId + branchIds;
1774
- withContext(branchIdKey, branchId, () => cb(item, index));
1772
+ withBranchId(branchId, () => {
1773
+ cb(item, index);
1774
+ loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
1775
+ });
1775
1776
  });
1777
+ if (loopScopes.size) {
1778
+ writeScope(scopeId, {
1779
+ ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1780
+ });
1781
+ }
1776
1782
  $chunk.writeHTML(
1777
1783
  $chunk.boundary.state.mark(
1778
1784
  onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
@@ -1780,7 +1786,17 @@ function resumeSingleNodeForOf(list, cb, scopeId, accessor, onlyChildInParent) {
1780
1786
  )
1781
1787
  );
1782
1788
  }
1783
- function resumeForIn(obj, cb, scopeId, accessor) {
1789
+ function forOfBy(by, item, index) {
1790
+ if (by) {
1791
+ if (typeof by === "string") {
1792
+ return item[by];
1793
+ }
1794
+ return by(item, index);
1795
+ }
1796
+ return index;
1797
+ }
1798
+ function resumeForIn(obj, cb, by, scopeId, accessor) {
1799
+ const loopScopes = /* @__PURE__ */ new Map();
1784
1800
  let sep = "";
1785
1801
  forIn(obj, (key, value) => {
1786
1802
  const branchId = peekNextScopeId();
@@ -1788,8 +1804,16 @@ function resumeForIn(obj, cb, scopeId, accessor) {
1788
1804
  $chunk.boundary.state.mark("[" /* BranchStart */, branchId + sep)
1789
1805
  );
1790
1806
  sep = " ";
1791
- withContext(branchIdKey, branchId, () => cb(key, value));
1807
+ withBranchId(branchId, () => {
1808
+ cb(key, value);
1809
+ loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
1810
+ });
1792
1811
  });
1812
+ if (loopScopes.size) {
1813
+ writeScope(scopeId, {
1814
+ ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1815
+ });
1816
+ }
1793
1817
  $chunk.writeHTML(
1794
1818
  $chunk.boundary.state.mark(
1795
1819
  "]" /* BranchEnd */,
@@ -1797,13 +1821,22 @@ function resumeForIn(obj, cb, scopeId, accessor) {
1797
1821
  )
1798
1822
  );
1799
1823
  }
1800
- function resumeSingleNodeForIn(obj, cb, scopeId, accessor, onlyChild) {
1824
+ function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, onlyChild) {
1825
+ const loopScopes = /* @__PURE__ */ new Map();
1801
1826
  let branchIds = "";
1802
1827
  forIn(obj, (key, value) => {
1803
1828
  const branchId = peekNextScopeId();
1804
1829
  branchIds = " " + branchId + branchIds;
1805
- withContext(branchIdKey, branchId, () => cb(key, value));
1830
+ withBranchId(branchId, () => {
1831
+ cb(key, value);
1832
+ loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
1833
+ });
1806
1834
  });
1835
+ if (loopScopes.size) {
1836
+ writeScope(scopeId, {
1837
+ ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1838
+ });
1839
+ }
1807
1840
  $chunk.writeHTML(
1808
1841
  $chunk.boundary.state.mark(
1809
1842
  onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
@@ -1811,7 +1844,14 @@ function resumeSingleNodeForIn(obj, cb, scopeId, accessor, onlyChild) {
1811
1844
  )
1812
1845
  );
1813
1846
  }
1814
- function resumeForTo(to, from, step, cb, scopeId, accessor) {
1847
+ function forInBy(by, name, value) {
1848
+ if (by) {
1849
+ return by(name, value);
1850
+ }
1851
+ return name;
1852
+ }
1853
+ function resumeForTo(to, from, step, cb, by, scopeId, accessor) {
1854
+ const loopScopes = /* @__PURE__ */ new Map();
1815
1855
  let sep = "";
1816
1856
  forTo(to, from, step, (index) => {
1817
1857
  const branchId = peekNextScopeId();
@@ -1819,8 +1859,16 @@ function resumeForTo(to, from, step, cb, scopeId, accessor) {
1819
1859
  $chunk.boundary.state.mark("[" /* BranchStart */, branchId + sep)
1820
1860
  );
1821
1861
  sep = " ";
1822
- withContext(branchIdKey, branchId, () => cb(index));
1862
+ withBranchId(branchId, () => {
1863
+ cb(index);
1864
+ loopScopes.set(forToBy(by, index), writeScope(branchId, {}));
1865
+ });
1823
1866
  });
1867
+ if (loopScopes.size) {
1868
+ writeScope(scopeId, {
1869
+ ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1870
+ });
1871
+ }
1824
1872
  $chunk.writeHTML(
1825
1873
  $chunk.boundary.state.mark(
1826
1874
  "]" /* BranchEnd */,
@@ -1828,13 +1876,22 @@ function resumeForTo(to, from, step, cb, scopeId, accessor) {
1828
1876
  )
1829
1877
  );
1830
1878
  }
1831
- function resumeSingleNodeForTo(to, from, step, cb, scopeId, accessor, onlyChild) {
1879
+ function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, onlyChild) {
1880
+ const loopScopes = /* @__PURE__ */ new Map();
1832
1881
  let branchIds = "";
1833
1882
  forTo(to, from, step, (index) => {
1834
1883
  const branchId = peekNextScopeId();
1835
1884
  branchIds = " " + branchId + branchIds;
1836
- withContext(branchIdKey, branchId, () => cb(index));
1885
+ withBranchId(branchId, () => {
1886
+ cb(index);
1887
+ loopScopes.set(forToBy(by, index), writeScope(branchId, {}));
1888
+ });
1837
1889
  });
1890
+ if (loopScopes.size) {
1891
+ writeScope(scopeId, {
1892
+ ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1893
+ });
1894
+ }
1838
1895
  $chunk.writeHTML(
1839
1896
  $chunk.boundary.state.mark(
1840
1897
  onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
@@ -1842,40 +1899,57 @@ function resumeSingleNodeForTo(to, from, step, cb, scopeId, accessor, onlyChild)
1842
1899
  )
1843
1900
  );
1844
1901
  }
1845
- function resumeConditional(cb, scopeId, accessor) {
1902
+ function forToBy(by, index) {
1903
+ if (by) {
1904
+ return by(index);
1905
+ }
1906
+ return index;
1907
+ }
1908
+ function resumeConditional(cb, scopeId, accessor, dynamic) {
1846
1909
  const branchId = peekNextScopeId();
1847
- $chunk.writeHTML(
1848
- $chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
1849
- );
1850
- withContext(branchIdKey, branchId, cb);
1851
- const rendered = peekNextScopeId() !== branchId;
1852
- if (rendered) {
1853
- writeScope(branchId, {});
1910
+ if (dynamic) {
1911
+ $chunk.writeHTML(
1912
+ $chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
1913
+ );
1914
+ }
1915
+ const branchIndex = withBranchId(branchId, cb);
1916
+ if (branchIndex !== void 0) {
1917
+ writeScope(scopeId, {
1918
+ ["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: dynamic ? branchIndex : void 0,
1919
+ ["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
1920
+ });
1854
1921
  } else {
1855
1922
  nextScopeId();
1856
1923
  }
1857
- $chunk.writeHTML(
1858
- $chunk.boundary.state.mark(
1859
- "]" /* BranchEnd */,
1860
- scopeId + " " + accessor
1861
- )
1862
- );
1924
+ if (dynamic) {
1925
+ $chunk.writeHTML(
1926
+ $chunk.boundary.state.mark(
1927
+ "]" /* BranchEnd */,
1928
+ scopeId + " " + accessor
1929
+ )
1930
+ );
1931
+ }
1863
1932
  }
1864
- function resumeSingleNodeConditional(cb, scopeId, accessor, onlyChild) {
1933
+ function resumeSingleNodeConditional(cb, scopeId, accessor, dynamic, onlyChild) {
1865
1934
  const branchId = peekNextScopeId();
1866
- withContext(branchIdKey, branchId, cb);
1867
- const rendered = peekNextScopeId() !== branchId;
1935
+ const branchIndex = withBranchId(branchId, cb);
1936
+ const rendered = branchIndex !== void 0;
1868
1937
  if (rendered) {
1869
- writeScope(branchId, {});
1938
+ writeScope(scopeId, {
1939
+ ["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: dynamic ? branchIndex : void 0,
1940
+ ["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
1941
+ });
1870
1942
  } else {
1871
1943
  nextScopeId();
1872
1944
  }
1873
- $chunk.writeHTML(
1874
- $chunk.boundary.state.mark(
1875
- onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1876
- scopeId + " " + accessor + (rendered ? " " + branchId : "")
1877
- )
1878
- );
1945
+ if (dynamic) {
1946
+ $chunk.writeHTML(
1947
+ $chunk.boundary.state.mark(
1948
+ onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1949
+ scopeId + " " + accessor + (rendered ? " " + branchId : "")
1950
+ )
1951
+ );
1952
+ }
1879
1953
  }
1880
1954
  var writeScope = (scopeId, partialScope) => {
1881
1955
  const { state } = $chunk.boundary;
@@ -2341,8 +2415,8 @@ function prepareChunk(chunk) {
2341
2415
  let cur = reorderedChunk;
2342
2416
  reorderedChunk.reorderId = null;
2343
2417
  for (; ; ) {
2344
- const { next } = cur;
2345
2418
  cur.flushPlaceholder();
2419
+ const { next } = cur;
2346
2420
  cur.consumed = true;
2347
2421
  reorderHTML += cur.html;
2348
2422
  reorderEffects = concatEffects(reorderEffects, cur.effects);
@@ -2728,117 +2802,97 @@ var DEFAULT_RENDER_ID = "_";
2728
2802
 
2729
2803
  // src/html/dynamic-tag.ts
2730
2804
  var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
2731
- function dynamicTagId(tagName) {
2732
- const normalizedRenderer = normalizeDynamicRenderer(tagName);
2733
- return normalizedRenderer?.___id || normalizedRenderer;
2734
- }
2735
- var dynamicTagInput = (scopeId, accessor, tag, input, content) => {
2736
- if (!tag && !content) {
2737
- nextScopeId();
2738
- return;
2739
- }
2740
- if (!tag) {
2741
- resumeConditional(content, scopeId, accessor);
2742
- return;
2805
+ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, resume) => {
2806
+ const renderer = normalizeDynamicRenderer(tag);
2807
+ if (true) {
2808
+ if (renderer && typeof renderer !== "function" && typeof renderer !== "string") {
2809
+ throw new Error(`Invalid renderer passed for dynamic tag: ${renderer}`);
2810
+ }
2743
2811
  }
2744
- if (typeof tag === "string") {
2745
- resumeSingleNodeConditional(
2746
- () => {
2747
- nextScopeId();
2748
- write(`<${tag}${attrs(input, accessor, scopeId, tag)}>`);
2749
- if (!voidElementsReg.test(tag)) {
2750
- if (tag === "textarea") {
2751
- if (content) {
2752
- throw new Error(
2753
- "A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead."
2754
- );
2755
- }
2756
- write(
2757
- controllable_textarea_value(
2758
- scopeId,
2759
- accessor,
2760
- input.value,
2761
- input.valueChange
2762
- )
2812
+ const chunk = getChunk();
2813
+ const branchId = peekNextScopeId();
2814
+ let result;
2815
+ if (typeof renderer === "string") {
2816
+ const input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
2817
+ nextScopeId();
2818
+ write(`<${renderer}${attrs(input, accessor, scopeId, renderer)}>`);
2819
+ if (!voidElementsReg.test(renderer)) {
2820
+ withBranchId(branchId, () => {
2821
+ if (renderer === "textarea") {
2822
+ if (content) {
2823
+ throw new Error(
2824
+ "A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead."
2763
2825
  );
2764
- } else if (content) {
2765
- if (tag === "select" && ("value" in input || "valueChange" in input)) {
2766
- controllable_select_value(
2767
- scopeId,
2768
- accessor,
2769
- input.value,
2770
- input.valueChange,
2771
- content
2772
- );
2773
- } else {
2774
- content();
2775
- }
2776
2826
  }
2777
- write(`</${tag}>`);
2827
+ write(
2828
+ controllable_textarea_value(
2829
+ scopeId,
2830
+ accessor,
2831
+ input.value,
2832
+ input.valueChange
2833
+ )
2834
+ );
2778
2835
  } else if (content) {
2779
- throw new Error(`Body content is not supported for a "${tag}" tag.`);
2836
+ if (renderer === "select" && ("value" in input || "valueChange" in input)) {
2837
+ controllable_select_value(
2838
+ scopeId,
2839
+ accessor,
2840
+ input.value,
2841
+ input.valueChange,
2842
+ content
2843
+ );
2844
+ } else {
2845
+ content();
2846
+ }
2780
2847
  }
2781
- },
2782
- scopeId,
2783
- accessor
2784
- );
2785
- return;
2786
- }
2787
- const renderer = normalizeDynamicRenderer(
2788
- tag
2789
- );
2790
- if (true) {
2791
- if (typeof renderer !== "function") {
2792
- throw new Error(`Invalid renderer passed for dynamic tag: ${tag}`);
2848
+ });
2849
+ write(`</${renderer}>`);
2850
+ } else if (content) {
2851
+ throw new Error(`Body content is not supported for a "${renderer}" tag.`);
2852
+ }
2853
+ if (resume) {
2854
+ chunk.writeHTML(
2855
+ chunk.boundary.state.mark(
2856
+ "|" /* BranchSingleNode */,
2857
+ scopeId + " " + accessor + " " + branchId
2858
+ )
2859
+ );
2793
2860
  }
2794
- }
2795
- let result;
2796
- resumeConditional(
2797
- () => {
2798
- result = renderer(content ? { ...input, content } : input);
2799
- },
2800
- scopeId,
2801
- accessor
2802
- );
2803
- return result;
2804
- };
2805
- var dynamicTagArgs = (scopeId, accessor, tag, args) => {
2806
- if (!tag) {
2807
- nextScopeId();
2808
- return;
2809
- }
2810
- if (typeof tag === "string") {
2811
- resumeSingleNodeConditional(
2812
- () => {
2813
- nextScopeId();
2814
- write(
2815
- `<${tag}${attrs(args[0], accessor, scopeId, tag)}>`
2861
+ } else {
2862
+ if (resume) {
2863
+ chunk.writeHTML(
2864
+ chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
2865
+ );
2866
+ }
2867
+ result = withBranchId(branchId, () => {
2868
+ if (renderer) {
2869
+ return inputIsArgs ? renderer(...inputOrArgs) : renderer(
2870
+ content ? { ...inputOrArgs, content } : inputOrArgs
2816
2871
  );
2817
- if (!voidElementsReg.test(tag)) {
2818
- write(`</${tag}>`);
2819
- }
2820
- },
2821
- scopeId,
2822
- accessor
2823
- );
2824
- return;
2872
+ } else if (content) {
2873
+ return content();
2874
+ }
2875
+ });
2876
+ if (resume) {
2877
+ chunk.writeHTML(
2878
+ chunk.boundary.state.mark(
2879
+ "]" /* BranchEnd */,
2880
+ scopeId + " " + accessor
2881
+ )
2882
+ );
2883
+ }
2825
2884
  }
2826
- const renderer = normalizeDynamicRenderer(
2827
- tag
2828
- );
2829
- if (true) {
2830
- if (typeof renderer !== "function") {
2831
- throw new Error(`Invalid renderer passed for dynamic tag: ${tag}`);
2885
+ const rendered = peekNextScopeId() !== branchId;
2886
+ if (rendered) {
2887
+ if (resume) {
2888
+ writeScope(scopeId, {
2889
+ ["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {}),
2890
+ ["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: renderer?.___id || renderer
2891
+ });
2832
2892
  }
2893
+ } else {
2894
+ nextScopeId();
2833
2895
  }
2834
- let result;
2835
- resumeConditional(
2836
- () => {
2837
- result = renderer(...args);
2838
- },
2839
- scopeId,
2840
- accessor
2841
- );
2842
2896
  return result;
2843
2897
  };
2844
2898
  function createContent(id, fn) {
@@ -2849,19 +2903,19 @@ function registerContent(id, fn, scopeId) {
2849
2903
  return register2(createContent(id, fn), id, scopeId);
2850
2904
  }
2851
2905
  function patchDynamicTag(patch) {
2852
- dynamicTagInput = /* @__PURE__ */ ((originalDynamicTagInput) => (scopeId, accessor, tag, input, content) => originalDynamicTagInput(
2853
- scopeId,
2854
- accessor,
2855
- patch(scopeId, accessor, tag),
2856
- input,
2857
- content
2858
- ))(dynamicTagInput);
2859
- dynamicTagArgs = /* @__PURE__ */ ((originalDynamicTagArgs) => (scopeId, accessor, tag, args) => originalDynamicTagArgs(
2860
- scopeId,
2861
- accessor,
2862
- patch(scopeId, accessor, tag),
2863
- args
2864
- ))(dynamicTagArgs);
2906
+ dynamicTag = /* @__PURE__ */ ((originalDynamicTag) => (scopeId, accessor, tag, input, content, inputIsArgs, resume) => {
2907
+ const patched = patch(scopeId, accessor, tag);
2908
+ patched.___id = tag;
2909
+ return originalDynamicTag(
2910
+ scopeId,
2911
+ accessor,
2912
+ patched,
2913
+ input,
2914
+ content,
2915
+ inputIsArgs,
2916
+ resume
2917
+ );
2918
+ })(dynamicTag);
2865
2919
  }
2866
2920
 
2867
2921
  // src/html/compat.ts
@@ -2961,7 +3015,7 @@ var compat = {
2961
3015
  };
2962
3016
 
2963
3017
  // src/html/for.ts
2964
- function forOfBy(by, item, index) {
3018
+ function forOfBy2(by, item, index) {
2965
3019
  if (by) {
2966
3020
  if (typeof by === "string") {
2967
3021
  return item[by];
@@ -2970,13 +3024,13 @@ function forOfBy(by, item, index) {
2970
3024
  }
2971
3025
  return index;
2972
3026
  }
2973
- function forInBy(by, name, value) {
3027
+ function forInBy2(by, name, value) {
2974
3028
  if (by) {
2975
3029
  return by(name, value);
2976
3030
  }
2977
3031
  return name;
2978
3032
  }
2979
- function forToBy(by, index) {
3033
+ function forToBy2(by, index) {
2980
3034
  if (by) {
2981
3035
  return by(index);
2982
3036
  }
@@ -3222,9 +3276,7 @@ function NOOP2() {
3222
3276
  controllable_textarea_value,
3223
3277
  createContent,
3224
3278
  createTemplate,
3225
- dynamicTagArgs,
3226
- dynamicTagId,
3227
- dynamicTagInput,
3279
+ dynamicTag,
3228
3280
  ensureScopeWithId,
3229
3281
  escapeScript,
3230
3282
  escapeStyle,