marko 6.0.61 → 6.0.63

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.
@@ -1831,18 +1831,19 @@ function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMark
1831
1831
  const { state } = $chunk.boundary;
1832
1832
  const resumeBranch = serializeBranch !== 0;
1833
1833
  const resumeMarker = serializeMarker !== 0;
1834
- let singleNodeBranchIds = "";
1834
+ let flushBranchIds = "";
1835
1835
  if (resumeBranch) {
1836
1836
  const loopScopes = /* @__PURE__ */ new Map();
1837
1837
  forOf(list, (item, index) => {
1838
1838
  const branchId = _peek_scope_id();
1839
1839
  if (resumeMarker) {
1840
1840
  if (singleNode) {
1841
- singleNodeBranchIds = " " + branchId + singleNodeBranchIds;
1841
+ flushBranchIds = " " + branchId + flushBranchIds;
1842
1842
  } else {
1843
1843
  $chunk.writeHTML(
1844
- state.mark("[" /* BranchStart */, branchId + (index ? " " : ""))
1844
+ state.mark("[" /* BranchStart */, flushBranchIds)
1845
1845
  );
1846
+ flushBranchIds = branchId + "";
1846
1847
  }
1847
1848
  }
1848
1849
  withBranchId(branchId, () => {
@@ -1861,32 +1862,30 @@ function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMark
1861
1862
  writeBranchEnd(
1862
1863
  scopeId,
1863
1864
  accessor,
1865
+ resumeBranch,
1864
1866
  resumeMarker,
1865
1867
  parentEndTag,
1866
- resumeMarker && (!parentEndTag || resumeBranch) && (singleNode ? state.mark(
1867
- parentEndTag ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1868
- scopeId + " " + accessor + singleNodeBranchIds
1869
- ) : state.mark("]" /* BranchEnd */, scopeId + " " + accessor))
1868
+ singleNode,
1869
+ singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : ""
1870
1870
  );
1871
1871
  }
1872
1872
  function _for_in(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag, singleNode) {
1873
1873
  const { state } = $chunk.boundary;
1874
1874
  const resumeBranch = serializeBranch !== 0;
1875
1875
  const resumeMarker = serializeMarker !== 0;
1876
- let singleNodeBranchIds = "";
1876
+ let flushBranchIds = "";
1877
1877
  if (resumeBranch) {
1878
1878
  const loopScopes = /* @__PURE__ */ new Map();
1879
- let sep = "";
1880
1879
  forIn(obj, (key, value) => {
1881
1880
  const branchId = _peek_scope_id();
1882
1881
  if (resumeMarker) {
1883
1882
  if (singleNode) {
1884
- singleNodeBranchIds = " " + branchId + singleNodeBranchIds;
1883
+ flushBranchIds = " " + branchId + flushBranchIds;
1885
1884
  } else {
1886
1885
  $chunk.writeHTML(
1887
- state.mark("[" /* BranchStart */, branchId + sep)
1886
+ state.mark("[" /* BranchStart */, flushBranchIds)
1888
1887
  );
1889
- sep = " ";
1888
+ flushBranchIds = branchId + "";
1890
1889
  }
1891
1890
  }
1892
1891
  withBranchId(branchId, () => {
@@ -1905,32 +1904,30 @@ function _for_in(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarke
1905
1904
  writeBranchEnd(
1906
1905
  scopeId,
1907
1906
  accessor,
1907
+ resumeBranch,
1908
1908
  resumeMarker,
1909
1909
  parentEndTag,
1910
- resumeMarker && (!parentEndTag || resumeBranch) && (singleNode ? state.mark(
1911
- parentEndTag ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1912
- scopeId + " " + accessor + singleNodeBranchIds
1913
- ) : state.mark("]" /* BranchEnd */, scopeId + " " + accessor))
1910
+ singleNode,
1911
+ singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : ""
1914
1912
  );
1915
1913
  }
1916
1914
  function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag, singleNode) {
1917
1915
  const { state } = $chunk.boundary;
1918
1916
  const resumeBranch = serializeBranch !== 0;
1919
1917
  const resumeMarker = serializeMarker !== 0;
1920
- let singleNodeBranchIds = "";
1918
+ let flushBranchIds = "";
1921
1919
  if (resumeBranch) {
1922
1920
  const loopScopes = /* @__PURE__ */ new Map();
1923
- let sep = "";
1924
1921
  forTo(to, from, step, (i) => {
1925
1922
  const branchId = _peek_scope_id();
1926
1923
  if (resumeMarker) {
1927
1924
  if (singleNode) {
1928
- singleNodeBranchIds = " " + branchId + singleNodeBranchIds;
1925
+ flushBranchIds = " " + branchId + flushBranchIds;
1929
1926
  } else {
1930
1927
  $chunk.writeHTML(
1931
- state.mark("[" /* BranchStart */, branchId + sep)
1928
+ state.mark("[" /* BranchStart */, flushBranchIds)
1932
1929
  );
1933
- sep = " ";
1930
+ flushBranchIds = branchId + "";
1934
1931
  }
1935
1932
  }
1936
1933
  withBranchId(branchId, () => {
@@ -1949,12 +1946,11 @@ function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, ser
1949
1946
  writeBranchEnd(
1950
1947
  scopeId,
1951
1948
  accessor,
1949
+ resumeBranch,
1952
1950
  resumeMarker,
1953
1951
  parentEndTag,
1954
- resumeMarker && (!parentEndTag || resumeBranch) && (singleNode ? state.mark(
1955
- parentEndTag ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1956
- scopeId + " " + accessor + singleNodeBranchIds
1957
- ) : state.mark("]" /* BranchEnd */, scopeId + " " + accessor))
1952
+ singleNode,
1953
+ singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : ""
1958
1954
  );
1959
1955
  }
1960
1956
  function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag, singleNode) {
@@ -1963,7 +1959,7 @@ function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, parentEndT
1963
1959
  const resumeMarker = serializeMarker !== 0;
1964
1960
  const branchId = _peek_scope_id();
1965
1961
  if (resumeMarker && resumeBranch && !singleNode) {
1966
- $chunk.writeHTML(state.mark("[" /* BranchStart */, branchId + ""));
1962
+ $chunk.writeHTML(state.mark("[" /* BranchStart */, ""));
1967
1963
  }
1968
1964
  const branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb();
1969
1965
  const shouldWriteBranch = resumeBranch && branchIndex !== void 0;
@@ -1976,18 +1972,25 @@ function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, parentEndT
1976
1972
  writeBranchEnd(
1977
1973
  scopeId,
1978
1974
  accessor,
1975
+ resumeBranch,
1979
1976
  resumeMarker,
1980
1977
  parentEndTag,
1981
- resumeMarker && (!parentEndTag || resumeBranch) && (singleNode ? state.mark(
1982
- parentEndTag ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1983
- scopeId + " " + accessor + (shouldWriteBranch ? " " + branchId : "")
1984
- ) : state.mark("]" /* BranchEnd */, scopeId + " " + accessor))
1978
+ singleNode,
1979
+ shouldWriteBranch ? " " + branchId : ""
1985
1980
  );
1986
1981
  }
1987
- function writeBranchEnd(scopeId, accessor, resumeMarker, parentEndTag, mark) {
1982
+ function writeBranchEnd(scopeId, accessor, resumeBranch, resumeMarker, parentEndTag, singleNode, branchIds) {
1988
1983
  const endTag = parentEndTag || "";
1989
1984
  if (resumeMarker) {
1990
- if (mark) {
1985
+ if (!parentEndTag || resumeBranch) {
1986
+ const { state } = $chunk.boundary;
1987
+ const mark = singleNode ? state.mark(
1988
+ parentEndTag ? "}" /* BranchEndSingleNodeOnlyChildInParent */ : "|" /* BranchEndSingleNode */,
1989
+ scopeId + " " + accessor + (branchIds || "")
1990
+ ) : state.mark(
1991
+ parentEndTag ? ")" /* BranchEndOnlyChildInParent */ : "]" /* BranchEnd */,
1992
+ scopeId + " " + accessor + (branchIds || "")
1993
+ );
1991
1994
  $chunk.writeHTML(mark + endTag);
1992
1995
  } else {
1993
1996
  $chunk.writeHTML(endTag + _el_resume(scopeId, accessor));
@@ -2047,7 +2050,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
2047
2050
  if (resumeMarker) {
2048
2051
  const branchId = _peek_scope_id();
2049
2052
  $chunk.writeHTML(
2050
- $chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
2053
+ $chunk.boundary.state.mark("[" /* BranchStart */, "")
2051
2054
  );
2052
2055
  content(promise);
2053
2056
  writeScope(scopeId, {
@@ -2056,7 +2059,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
2056
2059
  $chunk.writeHTML(
2057
2060
  $chunk.boundary.state.mark(
2058
2061
  "]" /* BranchEnd */,
2059
- scopeId + " " + accessor
2062
+ scopeId + " " + accessor + " " + branchId
2060
2063
  )
2061
2064
  );
2062
2065
  } else {
@@ -2081,10 +2084,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
2081
2084
  if (resumeMarker) {
2082
2085
  const branchId = _peek_scope_id();
2083
2086
  $chunk.writeHTML(
2084
- $chunk.boundary.state.mark(
2085
- "[" /* BranchStart */,
2086
- branchId + ""
2087
- )
2087
+ $chunk.boundary.state.mark("[" /* BranchStart */, "")
2088
2088
  );
2089
2089
  content(value);
2090
2090
  boundary.state.serializer.writeAssign(
@@ -2095,7 +2095,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
2095
2095
  $chunk.writeHTML(
2096
2096
  $chunk.boundary.state.mark(
2097
2097
  "]" /* BranchEnd */,
2098
- scopeId + " " + accessor
2098
+ scopeId + " " + accessor + " " + branchId
2099
2099
  )
2100
2100
  );
2101
2101
  } else {
@@ -2114,9 +2114,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
2114
2114
  }
2115
2115
  function _try(scopeId, accessor, content, input) {
2116
2116
  const branchId = _peek_scope_id();
2117
- $chunk.writeHTML(
2118
- $chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
2119
- );
2117
+ $chunk.writeHTML($chunk.boundary.state.mark("[" /* BranchStart */, ""));
2120
2118
  const catchContent = normalizeDynamicRenderer(input.catch);
2121
2119
  const placeholderContent = normalizeDynamicRenderer(input.placeholder);
2122
2120
  if (catchContent) {
@@ -2140,7 +2138,7 @@ function _try(scopeId, accessor, content, input) {
2140
2138
  $chunk.writeHTML(
2141
2139
  $chunk.boundary.state.mark(
2142
2140
  "]" /* BranchEnd */,
2143
- scopeId + " " + accessor
2141
+ scopeId + " " + accessor + " " + branchId
2144
2142
  )
2145
2143
  );
2146
2144
  }
@@ -3129,9 +3127,11 @@ var _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
3129
3127
  }
3130
3128
  const state = getState();
3131
3129
  const branchId = _peek_scope_id();
3130
+ let rendered = false;
3132
3131
  let result;
3133
3132
  if (typeof renderer === "string") {
3134
3133
  const input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
3134
+ rendered = true;
3135
3135
  _scope_id();
3136
3136
  _html(
3137
3137
  `<${renderer}${_attrs(input, true ? `#${renderer}/0` : 0, branchId, renderer)}>`
@@ -3187,14 +3187,14 @@ var _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
3187
3187
  if (shouldResume) {
3188
3188
  _html(
3189
3189
  state.mark(
3190
- "'" /* BranchNativeTag */,
3190
+ "'" /* BranchEndNativeTag */,
3191
3191
  scopeId + " " + accessor + " " + branchId
3192
3192
  )
3193
3193
  );
3194
3194
  }
3195
3195
  } else {
3196
3196
  if (shouldResume) {
3197
- _html(state.mark("[" /* BranchStart */, branchId + ""));
3197
+ _html(state.mark("[" /* BranchStart */, ""));
3198
3198
  }
3199
3199
  const render2 = () => {
3200
3200
  if (renderer) {
@@ -3213,11 +3213,16 @@ var _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
3213
3213
  }
3214
3214
  };
3215
3215
  result = shouldResume ? withBranchId(branchId, render2) : render2();
3216
+ rendered = _peek_scope_id() !== branchId;
3216
3217
  if (shouldResume) {
3217
- _html(state.mark("]" /* BranchEnd */, scopeId + " " + accessor));
3218
+ _html(
3219
+ state.mark(
3220
+ "]" /* BranchEnd */,
3221
+ scopeId + " " + accessor + (rendered ? " " + branchId : "")
3222
+ )
3223
+ );
3218
3224
  }
3219
3225
  }
3220
- const rendered = _peek_scope_id() !== branchId;
3221
3226
  if (rendered) {
3222
3227
  if (shouldResume) {
3223
3228
  writeScope(scopeId, {
@@ -1747,18 +1747,19 @@ function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMark
1747
1747
  const { state } = $chunk.boundary;
1748
1748
  const resumeBranch = serializeBranch !== 0;
1749
1749
  const resumeMarker = serializeMarker !== 0;
1750
- let singleNodeBranchIds = "";
1750
+ let flushBranchIds = "";
1751
1751
  if (resumeBranch) {
1752
1752
  const loopScopes = /* @__PURE__ */ new Map();
1753
1753
  forOf(list, (item, index) => {
1754
1754
  const branchId = _peek_scope_id();
1755
1755
  if (resumeMarker) {
1756
1756
  if (singleNode) {
1757
- singleNodeBranchIds = " " + branchId + singleNodeBranchIds;
1757
+ flushBranchIds = " " + branchId + flushBranchIds;
1758
1758
  } else {
1759
1759
  $chunk.writeHTML(
1760
- state.mark("[" /* BranchStart */, branchId + (index ? " " : ""))
1760
+ state.mark("[" /* BranchStart */, flushBranchIds)
1761
1761
  );
1762
+ flushBranchIds = branchId + "";
1762
1763
  }
1763
1764
  }
1764
1765
  withBranchId(branchId, () => {
@@ -1777,32 +1778,30 @@ function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMark
1777
1778
  writeBranchEnd(
1778
1779
  scopeId,
1779
1780
  accessor,
1781
+ resumeBranch,
1780
1782
  resumeMarker,
1781
1783
  parentEndTag,
1782
- resumeMarker && (!parentEndTag || resumeBranch) && (singleNode ? state.mark(
1783
- parentEndTag ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1784
- scopeId + " " + accessor + singleNodeBranchIds
1785
- ) : state.mark("]" /* BranchEnd */, scopeId + " " + accessor))
1784
+ singleNode,
1785
+ singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : ""
1786
1786
  );
1787
1787
  }
1788
1788
  function _for_in(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag, singleNode) {
1789
1789
  const { state } = $chunk.boundary;
1790
1790
  const resumeBranch = serializeBranch !== 0;
1791
1791
  const resumeMarker = serializeMarker !== 0;
1792
- let singleNodeBranchIds = "";
1792
+ let flushBranchIds = "";
1793
1793
  if (resumeBranch) {
1794
1794
  const loopScopes = /* @__PURE__ */ new Map();
1795
- let sep = "";
1796
1795
  forIn(obj, (key, value) => {
1797
1796
  const branchId = _peek_scope_id();
1798
1797
  if (resumeMarker) {
1799
1798
  if (singleNode) {
1800
- singleNodeBranchIds = " " + branchId + singleNodeBranchIds;
1799
+ flushBranchIds = " " + branchId + flushBranchIds;
1801
1800
  } else {
1802
1801
  $chunk.writeHTML(
1803
- state.mark("[" /* BranchStart */, branchId + sep)
1802
+ state.mark("[" /* BranchStart */, flushBranchIds)
1804
1803
  );
1805
- sep = " ";
1804
+ flushBranchIds = branchId + "";
1806
1805
  }
1807
1806
  }
1808
1807
  withBranchId(branchId, () => {
@@ -1821,32 +1820,30 @@ function _for_in(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarke
1821
1820
  writeBranchEnd(
1822
1821
  scopeId,
1823
1822
  accessor,
1823
+ resumeBranch,
1824
1824
  resumeMarker,
1825
1825
  parentEndTag,
1826
- resumeMarker && (!parentEndTag || resumeBranch) && (singleNode ? state.mark(
1827
- parentEndTag ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1828
- scopeId + " " + accessor + singleNodeBranchIds
1829
- ) : state.mark("]" /* BranchEnd */, scopeId + " " + accessor))
1826
+ singleNode,
1827
+ singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : ""
1830
1828
  );
1831
1829
  }
1832
1830
  function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag, singleNode) {
1833
1831
  const { state } = $chunk.boundary;
1834
1832
  const resumeBranch = serializeBranch !== 0;
1835
1833
  const resumeMarker = serializeMarker !== 0;
1836
- let singleNodeBranchIds = "";
1834
+ let flushBranchIds = "";
1837
1835
  if (resumeBranch) {
1838
1836
  const loopScopes = /* @__PURE__ */ new Map();
1839
- let sep = "";
1840
1837
  forTo(to, from, step, (i) => {
1841
1838
  const branchId = _peek_scope_id();
1842
1839
  if (resumeMarker) {
1843
1840
  if (singleNode) {
1844
- singleNodeBranchIds = " " + branchId + singleNodeBranchIds;
1841
+ flushBranchIds = " " + branchId + flushBranchIds;
1845
1842
  } else {
1846
1843
  $chunk.writeHTML(
1847
- state.mark("[" /* BranchStart */, branchId + sep)
1844
+ state.mark("[" /* BranchStart */, flushBranchIds)
1848
1845
  );
1849
- sep = " ";
1846
+ flushBranchIds = branchId + "";
1850
1847
  }
1851
1848
  }
1852
1849
  withBranchId(branchId, () => {
@@ -1865,12 +1862,11 @@ function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, ser
1865
1862
  writeBranchEnd(
1866
1863
  scopeId,
1867
1864
  accessor,
1865
+ resumeBranch,
1868
1866
  resumeMarker,
1869
1867
  parentEndTag,
1870
- resumeMarker && (!parentEndTag || resumeBranch) && (singleNode ? state.mark(
1871
- parentEndTag ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1872
- scopeId + " " + accessor + singleNodeBranchIds
1873
- ) : state.mark("]" /* BranchEnd */, scopeId + " " + accessor))
1868
+ singleNode,
1869
+ singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : ""
1874
1870
  );
1875
1871
  }
1876
1872
  function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag, singleNode) {
@@ -1879,7 +1875,7 @@ function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, parentEndT
1879
1875
  const resumeMarker = serializeMarker !== 0;
1880
1876
  const branchId = _peek_scope_id();
1881
1877
  if (resumeMarker && resumeBranch && !singleNode) {
1882
- $chunk.writeHTML(state.mark("[" /* BranchStart */, branchId + ""));
1878
+ $chunk.writeHTML(state.mark("[" /* BranchStart */, ""));
1883
1879
  }
1884
1880
  const branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb();
1885
1881
  const shouldWriteBranch = resumeBranch && branchIndex !== void 0;
@@ -1892,18 +1888,25 @@ function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, parentEndT
1892
1888
  writeBranchEnd(
1893
1889
  scopeId,
1894
1890
  accessor,
1891
+ resumeBranch,
1895
1892
  resumeMarker,
1896
1893
  parentEndTag,
1897
- resumeMarker && (!parentEndTag || resumeBranch) && (singleNode ? state.mark(
1898
- parentEndTag ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1899
- scopeId + " " + accessor + (shouldWriteBranch ? " " + branchId : "")
1900
- ) : state.mark("]" /* BranchEnd */, scopeId + " " + accessor))
1894
+ singleNode,
1895
+ shouldWriteBranch ? " " + branchId : ""
1901
1896
  );
1902
1897
  }
1903
- function writeBranchEnd(scopeId, accessor, resumeMarker, parentEndTag, mark) {
1898
+ function writeBranchEnd(scopeId, accessor, resumeBranch, resumeMarker, parentEndTag, singleNode, branchIds) {
1904
1899
  const endTag = parentEndTag || "";
1905
1900
  if (resumeMarker) {
1906
- if (mark) {
1901
+ if (!parentEndTag || resumeBranch) {
1902
+ const { state } = $chunk.boundary;
1903
+ const mark = singleNode ? state.mark(
1904
+ parentEndTag ? "}" /* BranchEndSingleNodeOnlyChildInParent */ : "|" /* BranchEndSingleNode */,
1905
+ scopeId + " " + accessor + (branchIds || "")
1906
+ ) : state.mark(
1907
+ parentEndTag ? ")" /* BranchEndOnlyChildInParent */ : "]" /* BranchEnd */,
1908
+ scopeId + " " + accessor + (branchIds || "")
1909
+ );
1907
1910
  $chunk.writeHTML(mark + endTag);
1908
1911
  } else {
1909
1912
  $chunk.writeHTML(endTag + _el_resume(scopeId, accessor));
@@ -1963,7 +1966,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
1963
1966
  if (resumeMarker) {
1964
1967
  const branchId = _peek_scope_id();
1965
1968
  $chunk.writeHTML(
1966
- $chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
1969
+ $chunk.boundary.state.mark("[" /* BranchStart */, "")
1967
1970
  );
1968
1971
  content(promise);
1969
1972
  writeScope(scopeId, {
@@ -1972,7 +1975,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
1972
1975
  $chunk.writeHTML(
1973
1976
  $chunk.boundary.state.mark(
1974
1977
  "]" /* BranchEnd */,
1975
- scopeId + " " + accessor
1978
+ scopeId + " " + accessor + " " + branchId
1976
1979
  )
1977
1980
  );
1978
1981
  } else {
@@ -1997,10 +2000,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
1997
2000
  if (resumeMarker) {
1998
2001
  const branchId = _peek_scope_id();
1999
2002
  $chunk.writeHTML(
2000
- $chunk.boundary.state.mark(
2001
- "[" /* BranchStart */,
2002
- branchId + ""
2003
- )
2003
+ $chunk.boundary.state.mark("[" /* BranchStart */, "")
2004
2004
  );
2005
2005
  content(value);
2006
2006
  boundary.state.serializer.writeAssign(
@@ -2011,7 +2011,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
2011
2011
  $chunk.writeHTML(
2012
2012
  $chunk.boundary.state.mark(
2013
2013
  "]" /* BranchEnd */,
2014
- scopeId + " " + accessor
2014
+ scopeId + " " + accessor + " " + branchId
2015
2015
  )
2016
2016
  );
2017
2017
  } else {
@@ -2030,9 +2030,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
2030
2030
  }
2031
2031
  function _try(scopeId, accessor, content, input) {
2032
2032
  const branchId = _peek_scope_id();
2033
- $chunk.writeHTML(
2034
- $chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
2035
- );
2033
+ $chunk.writeHTML($chunk.boundary.state.mark("[" /* BranchStart */, ""));
2036
2034
  const catchContent = normalizeDynamicRenderer(input.catch);
2037
2035
  const placeholderContent = normalizeDynamicRenderer(input.placeholder);
2038
2036
  if (catchContent) {
@@ -2056,7 +2054,7 @@ function _try(scopeId, accessor, content, input) {
2056
2054
  $chunk.writeHTML(
2057
2055
  $chunk.boundary.state.mark(
2058
2056
  "]" /* BranchEnd */,
2059
- scopeId + " " + accessor
2057
+ scopeId + " " + accessor + " " + branchId
2060
2058
  )
2061
2059
  );
2062
2060
  }
@@ -3045,9 +3043,11 @@ var _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
3045
3043
  }
3046
3044
  const state = getState();
3047
3045
  const branchId = _peek_scope_id();
3046
+ let rendered = false;
3048
3047
  let result;
3049
3048
  if (typeof renderer === "string") {
3050
3049
  const input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
3050
+ rendered = true;
3051
3051
  _scope_id();
3052
3052
  _html(
3053
3053
  `<${renderer}${_attrs(input, true ? `#${renderer}/0` : 0, branchId, renderer)}>`
@@ -3103,14 +3103,14 @@ var _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
3103
3103
  if (shouldResume) {
3104
3104
  _html(
3105
3105
  state.mark(
3106
- "'" /* BranchNativeTag */,
3106
+ "'" /* BranchEndNativeTag */,
3107
3107
  scopeId + " " + accessor + " " + branchId
3108
3108
  )
3109
3109
  );
3110
3110
  }
3111
3111
  } else {
3112
3112
  if (shouldResume) {
3113
- _html(state.mark("[" /* BranchStart */, branchId + ""));
3113
+ _html(state.mark("[" /* BranchStart */, ""));
3114
3114
  }
3115
3115
  const render2 = () => {
3116
3116
  if (renderer) {
@@ -3129,11 +3129,16 @@ var _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
3129
3129
  }
3130
3130
  };
3131
3131
  result = shouldResume ? withBranchId(branchId, render2) : render2();
3132
+ rendered = _peek_scope_id() !== branchId;
3132
3133
  if (shouldResume) {
3133
- _html(state.mark("]" /* BranchEnd */, scopeId + " " + accessor));
3134
+ _html(
3135
+ state.mark(
3136
+ "]" /* BranchEnd */,
3137
+ scopeId + " " + accessor + (rendered ? " " + branchId : "")
3138
+ )
3139
+ );
3134
3140
  }
3135
3141
  }
3136
- const rendered = _peek_scope_id() !== branchId;
3137
3142
  if (rendered) {
3138
3143
  if (shouldResume) {
3139
3144
  writeScope(scopeId, {
package/dist/dom.js CHANGED
@@ -294,59 +294,50 @@ function init(runtimeId = "M") {
294
294
  let renders = self[runtimeId], defineRuntime = (desc) => Object.defineProperty(self, runtimeId, desc), resumeRender, initRuntime = (renders2) => {
295
295
  defineRuntime({
296
296
  value: resumeRender = ((renderId) => {
297
- let render = resumeRender[renderId] = renders2[renderId] || renders2(renderId), walk2 = render.w, commentPrefixLen = render.i.length, scopeLookup = render.s = {}, serializeContext = {
297
+ let render = resumeRender[renderId] = renders2[renderId] || renders2(renderId), walk2 = render.w, scopeLookup = render.s = {}, serializeContext = {
298
298
  _: registeredValues
299
299
  }, branches = branchesEnabled && /* @__PURE__ */ (() => {
300
- let branchStack = [], branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map(), lastEndNode, currentBranchId, endBranch = (branchId, reference) => {
301
- let branch = scopeLookup[branchId] ||= {}, endNode = reference, prevNode;
302
- for (; (prevNode = endNode.previousSibling) !== branch.h && ~visits.indexOf(endNode = prevNode); ) ;
303
- return branch.j = lastEndNode = endNode === lastEndNode ? reference.parentNode.insertBefore(new Text(), reference) : endNode, branch.h ||= lastEndNode, branchIds.add(branchId), branch;
300
+ let branchParents = /* @__PURE__ */ new Map(), branchStarts = [], orphanBranches = [], endBranch = (singleNode) => {
301
+ let parent = visit.parentNode, startVisit = visit, i = orphanBranches.length, claimed = 0, branchId, branch;
302
+ for (; branchId = +lastToken; ) {
303
+ if (branch = scopeLookup[branchId] ||= {}, singleNode) {
304
+ for (; startVisit.previousSibling && ~visits.indexOf(
305
+ startVisit = startVisit.previousSibling
306
+ ); ) ;
307
+ branch.j = branch.h = startVisit, visitType === "'" /* BranchEndNativeTag */ && (branch[0] = startVisit);
308
+ } else
309
+ startVisit = branchStarts.pop(), parent !== startVisit.parentNode && parent.prepend(startVisit), branch.h = startVisit, branch.j = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
310
+ for (; i-- && orphanBranches[i] > branchId; )
311
+ branchParents.set(orphanBranches[i], branchId), claimed++;
312
+ orphanBranches.push(branchId), branchParents.set(branchId, 0), nextToken();
313
+ }
314
+ orphanBranches.splice(i, claimed);
304
315
  };
305
316
  return {
306
317
  K() {
307
- if (visitToken === "[" /* BranchStart */)
308
- currentBranchId && visitDataIndex && (endBranch(currentBranchId, visit), currentBranchId = branchStack.pop()), currentBranchId && (branchStack.push(currentBranchId), parentBranchIds.set(scopeId, currentBranchId)), currentBranchId = scopeId, visitScope.h = visit;
309
- else if (visitToken === "]" /* BranchEnd */) {
310
- let curParent = visit.parentNode, startNode = endBranch(
311
- currentBranchId,
312
- visit
313
- ).h;
314
- visitScope[visitData] = visit, curParent !== startNode.parentNode && curParent.prepend(startNode), currentBranchId = branchStack.pop();
315
- } else {
316
- let next = visitData.indexOf(" "), curNode = visit;
317
- for (visitScope[~next ? visitData.slice(0, next) : visitData] = visitToken === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit; ~next; ) {
318
- let start = next + 1;
319
- next = visitData.indexOf(" ", start);
320
- let childScopeId = +visitData.slice(
321
- start,
322
- ~next ? next : visitData.length
323
- );
324
- if (curNode = endBranch(childScopeId, curNode).j, parentBranchIds.set(childScopeId, scopeId), visitToken === "'" /* BranchNativeTag */) {
325
- let childBranch = scopeLookup[childScopeId];
326
- childBranch[0] = childBranch.h = childBranch.j = curNode;
327
- }
328
- }
329
- }
318
+ visitType === "[" /* BranchStart */ ? (endBranch(), branchStarts.push(visit)) : (visitScope[
319
+ nextToken()
320
+ /* read accessor */
321
+ ] = visitType === ")" /* BranchEndOnlyChildInParent */ || visitType === "}" /* BranchEndSingleNodeOnlyChildInParent */ ? visit.parentNode : visit, nextToken(), endBranch(
322
+ visitType !== "]" /* BranchEnd */ && visitType !== ")" /* BranchEndOnlyChildInParent */
323
+ ));
330
324
  },
331
325
  t(scope) {
332
- let parentBranchId = scope.g || parentBranchIds.get(scopeId);
333
- if (parentBranchId && (scope.k = scopeLookup[parentBranchId]), branchIds.has(scopeId)) {
334
- let branch = scope, parentBranch = branch.k;
335
- scope.k = branch, parentBranch && (branch.y = parentBranch, (parentBranch.A ||= /* @__PURE__ */ new Set()).add(branch));
336
- }
326
+ scope.k = scopeLookup[scope.g || branchParents.get(scopeId)], branchParents.has(scopeId) && (scope.k && ((scope.y = scope.k).A ||= /* @__PURE__ */ new Set()).add(scope), scope.k = scope);
337
327
  }
338
328
  };
339
- })(), $global, lastScopeId = 0, lastEffect, visits, resumes, scopeId, visit, visitText, visitData, visitDataIndex, visitToken, visitScope;
329
+ })(), $global, lastScopeId = 0, lastEffect, visits, resumes, scopeId, visit, visitText, visitType, visitScope, lastToken, lastTokenIndex, nextToken = () => lastToken = visitText.slice(
330
+ lastTokenIndex,
331
+ // eslint-disable-next-line no-cond-assign
332
+ (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1) ? lastTokenIndex - 1 : visitText.length
333
+ );
340
334
  return render.w = () => {
341
335
  try {
342
336
  walk2(), isResuming = 1;
343
337
  for (visit of visits = render.v)
344
- visitText = visit.data, visitDataIndex = visitText.indexOf(" ") + 1, scopeId = +visitText.slice(
345
- commentPrefixLen + 1,
346
- visitDataIndex ? visitDataIndex - 1 : visitText.length
347
- ), visitData = visitDataIndex ? visitText.slice(visitDataIndex) : "", visitToken = visitText[commentPrefixLen], visitScope = scopeLookup[scopeId] ||= {
338
+ lastTokenIndex = render.i.length, visitText = visit.data, visitType = visitText[lastTokenIndex++], (scopeId = +nextToken()) && (visitScope = scopeLookup[scopeId] ||= {
348
339
  l: scopeId
349
- }, visitToken === "*" /* Node */ ? visitScope["j" /* Getter */ + visitData] = /* @__PURE__ */ ((node) => () => node)(visitScope[visitData] = visit.previousSibling) : branches && branches.K();
340
+ }), visitType === "*" /* Node */ ? visitScope["j" /* Getter */ + nextToken()] = /* @__PURE__ */ ((node) => () => node)(visitScope[lastToken] = visit.previousSibling) : branchesEnabled && branches.K();
350
341
  for (let serialized of resumes = render.r || [])
351
342
  if (typeof serialized == "string")
352
343
  lastEffect = serialized;
@@ -362,7 +353,7 @@ function init(runtimeId = "M") {
362
353
  $global ? typeof scope == "number" ? lastScopeId += scope : (scopeId = ++lastScopeId, scope.$global = $global, scope.l = scopeId, scopeLookup[scopeId] !== scope && (scopeLookup[scopeId] = Object.assign(
363
354
  scope,
364
355
  scopeLookup[scopeId]
365
- )), branches && branches.t(scope)) : ($global = scope || {}, $global.runtimeId = runtimeId, $global.renderId = renderId, $global.p = 1e6);
356
+ )), branchesEnabled && branches.t(scope)) : ($global = scope || {}, $global.runtimeId = runtimeId, $global.renderId = renderId, $global.p = 1e6);
366
357
  } finally {
367
358
  isResuming = visits.length = resumes.length = 0;
368
359
  }