marko 6.0.8 → 6.0.10

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.
@@ -1705,7 +1705,7 @@ var branchIdKey = Symbol();
1705
1705
  function withBranchId(branchId, cb) {
1706
1706
  return withContext(branchIdKey, branchId, cb);
1707
1707
  }
1708
- function resumeForOf(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker) {
1708
+ function resumeForOf(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag) {
1709
1709
  const resumeBranch = serializeBranch !== 0;
1710
1710
  const resumeMarker = serializeMarker !== 0;
1711
1711
  if (resumeBranch) {
@@ -1733,16 +1733,18 @@ function resumeForOf(list, cb, by, scopeId, accessor, serializeBranch, serialize
1733
1733
  } else {
1734
1734
  forOf(list, cb);
1735
1735
  }
1736
- if (resumeMarker) {
1737
- $chunk.writeHTML(
1738
- $chunk.boundary.state.mark(
1739
- "]" /* BranchEnd */,
1740
- scopeId + " " + accessor
1741
- )
1742
- );
1743
- }
1736
+ writeBranchEnd(
1737
+ scopeId,
1738
+ accessor,
1739
+ resumeMarker,
1740
+ parentEndTag,
1741
+ resumeMarker && (!parentEndTag || resumeBranch) && $chunk.boundary.state.mark(
1742
+ "]" /* BranchEnd */,
1743
+ scopeId + " " + accessor
1744
+ )
1745
+ );
1744
1746
  }
1745
- function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker, onlyChildInParent) {
1747
+ function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag) {
1746
1748
  const resumeBranch = serializeBranch !== 0;
1747
1749
  const resumeMarker = serializeMarker !== 0;
1748
1750
  let branchIds = "";
@@ -1766,16 +1768,18 @@ function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, serializeBranch,
1766
1768
  } else {
1767
1769
  forOf(list, cb);
1768
1770
  }
1769
- if (resumeMarker) {
1770
- $chunk.writeHTML(
1771
- $chunk.boundary.state.mark(
1772
- onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1773
- scopeId + " " + accessor + branchIds
1774
- )
1775
- );
1776
- }
1771
+ writeBranchEnd(
1772
+ scopeId,
1773
+ accessor,
1774
+ resumeMarker,
1775
+ parentEndTag,
1776
+ resumeMarker && (!parentEndTag || resumeBranch) && $chunk.boundary.state.mark(
1777
+ parentEndTag ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1778
+ scopeId + " " + accessor + branchIds
1779
+ )
1780
+ );
1777
1781
  }
1778
- function resumeForIn(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker) {
1782
+ function resumeForIn(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag) {
1779
1783
  const resumeBranch = serializeBranch !== 0;
1780
1784
  const resumeMarker = serializeMarker !== 0;
1781
1785
  if (resumeBranch) {
@@ -1802,16 +1806,18 @@ function resumeForIn(obj, cb, by, scopeId, accessor, serializeBranch, serializeM
1802
1806
  } else {
1803
1807
  forIn(obj, cb);
1804
1808
  }
1805
- if (resumeMarker) {
1806
- $chunk.writeHTML(
1807
- $chunk.boundary.state.mark(
1808
- "]" /* BranchEnd */,
1809
- scopeId + " " + accessor
1810
- )
1811
- );
1812
- }
1809
+ writeBranchEnd(
1810
+ scopeId,
1811
+ accessor,
1812
+ resumeMarker,
1813
+ parentEndTag,
1814
+ resumeMarker && (!parentEndTag || resumeBranch) && $chunk.boundary.state.mark(
1815
+ "]" /* BranchEnd */,
1816
+ scopeId + " " + accessor
1817
+ )
1818
+ );
1813
1819
  }
1814
- function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker, onlyChildInParent) {
1820
+ function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag) {
1815
1821
  const resumeBranch = serializeBranch !== 0;
1816
1822
  const resumeMarker = serializeMarker !== 0;
1817
1823
  let branchIds = "";
@@ -1835,16 +1841,18 @@ function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, serializeBranch,
1835
1841
  } else {
1836
1842
  forIn(obj, cb);
1837
1843
  }
1838
- if (resumeMarker) {
1839
- $chunk.writeHTML(
1840
- $chunk.boundary.state.mark(
1841
- onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1842
- scopeId + " " + accessor + branchIds
1843
- )
1844
- );
1845
- }
1844
+ writeBranchEnd(
1845
+ scopeId,
1846
+ accessor,
1847
+ resumeMarker,
1848
+ parentEndTag,
1849
+ resumeMarker && (!parentEndTag || resumeBranch) && $chunk.boundary.state.mark(
1850
+ parentEndTag ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1851
+ scopeId + " " + accessor + branchIds
1852
+ )
1853
+ );
1846
1854
  }
1847
- function resumeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker) {
1855
+ function resumeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag) {
1848
1856
  const resumeBranch = serializeBranch !== 0;
1849
1857
  const resumeMarker = serializeMarker !== 0;
1850
1858
  if (resumeBranch) {
@@ -1871,16 +1879,18 @@ function resumeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch,
1871
1879
  } else {
1872
1880
  forTo(to, from, step, cb);
1873
1881
  }
1874
- if (resumeMarker) {
1875
- $chunk.writeHTML(
1876
- $chunk.boundary.state.mark(
1877
- "]" /* BranchEnd */,
1878
- scopeId + " " + accessor
1879
- )
1880
- );
1881
- }
1882
+ writeBranchEnd(
1883
+ scopeId,
1884
+ accessor,
1885
+ resumeMarker,
1886
+ parentEndTag,
1887
+ resumeMarker && (!parentEndTag || resumeBranch) && $chunk.boundary.state.mark(
1888
+ "]" /* BranchEnd */,
1889
+ scopeId + " " + accessor
1890
+ )
1891
+ );
1882
1892
  }
1883
- function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, onlyChildInParent) {
1893
+ function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag) {
1884
1894
  const resumeBranch = serializeBranch !== 0;
1885
1895
  const resumeMarker = serializeMarker !== 0;
1886
1896
  let branchIds = "";
@@ -1904,16 +1914,18 @@ function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, serial
1904
1914
  } else {
1905
1915
  forTo(to, from, step, cb);
1906
1916
  }
1907
- if (resumeMarker) {
1908
- $chunk.writeHTML(
1909
- $chunk.boundary.state.mark(
1910
- onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1911
- scopeId + " " + accessor + branchIds
1912
- )
1913
- );
1914
- }
1917
+ writeBranchEnd(
1918
+ scopeId,
1919
+ accessor,
1920
+ resumeMarker,
1921
+ parentEndTag,
1922
+ resumeMarker && (!parentEndTag || resumeBranch) && $chunk.boundary.state.mark(
1923
+ parentEndTag ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1924
+ scopeId + " " + accessor + branchIds
1925
+ )
1926
+ );
1915
1927
  }
1916
- function resumeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker) {
1928
+ function resumeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag) {
1917
1929
  const resumeBranch = serializeBranch !== 0;
1918
1930
  const resumeMarker = serializeMarker !== 0;
1919
1931
  const branchId = peekNextScopeId();
@@ -1930,16 +1942,18 @@ function resumeConditional(cb, scopeId, accessor, serializeBranch, serializeMark
1930
1942
  ["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
1931
1943
  });
1932
1944
  }
1933
- if (resumeMarker) {
1934
- $chunk.writeHTML(
1935
- $chunk.boundary.state.mark(
1936
- "]" /* BranchEnd */,
1937
- scopeId + " " + accessor
1938
- )
1939
- );
1940
- }
1945
+ writeBranchEnd(
1946
+ scopeId,
1947
+ accessor,
1948
+ resumeMarker,
1949
+ parentEndTag,
1950
+ resumeMarker && (!parentEndTag || resumeBranch) && $chunk.boundary.state.mark(
1951
+ "]" /* BranchEnd */,
1952
+ scopeId + " " + accessor
1953
+ )
1954
+ );
1941
1955
  }
1942
- function resumeSingleNodeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker, onlyChildInParent) {
1956
+ function resumeSingleNodeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag) {
1943
1957
  const resumeBranch = serializeBranch !== 0;
1944
1958
  const resumeMarker = serializeMarker !== 0;
1945
1959
  const branchId = peekNextScopeId();
@@ -1951,13 +1965,27 @@ function resumeSingleNodeConditional(cb, scopeId, accessor, serializeBranch, ser
1951
1965
  ["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
1952
1966
  });
1953
1967
  }
1968
+ writeBranchEnd(
1969
+ scopeId,
1970
+ accessor,
1971
+ resumeMarker,
1972
+ parentEndTag,
1973
+ resumeMarker && (!parentEndTag || resumeBranch) && $chunk.boundary.state.mark(
1974
+ parentEndTag ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1975
+ scopeId + " " + accessor + (shouldWriteBranch ? " " + branchId : "")
1976
+ )
1977
+ );
1978
+ }
1979
+ function writeBranchEnd(scopeId, accessor, resumeMarker, parentEndTag, mark) {
1980
+ const endTag = parentEndTag || "";
1954
1981
  if (resumeMarker) {
1955
- $chunk.writeHTML(
1956
- $chunk.boundary.state.mark(
1957
- onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1958
- scopeId + " " + accessor + (shouldWriteBranch ? " " + branchId : "")
1959
- )
1960
- );
1982
+ if (mark) {
1983
+ $chunk.writeHTML(mark + endTag);
1984
+ } else {
1985
+ $chunk.writeHTML(endTag + markResumeNode(scopeId, accessor));
1986
+ }
1987
+ } else {
1988
+ $chunk.writeHTML(endTag);
1961
1989
  }
1962
1990
  }
1963
1991
  var writeScope = (scopeId, partialScope) => {
@@ -1,5 +1,7 @@
1
1
  import { type Scope } from "../common/types";
2
2
  import type { Signal } from "./signals";
3
+ export declare let branchesEnabled: undefined | 1;
4
+ export declare function enableBranches(): void;
3
5
  export declare function init(runtimeId?: string): void;
4
6
  export declare let isResuming: undefined | 0 | 1;
5
7
  export declare function register<T>(id: string, obj: T): T;
package/dist/dom.js CHANGED
@@ -201,7 +201,10 @@ function stripSpacesAndPunctuation(str) {
201
201
  var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
202
202
 
203
203
  // src/dom/resume.ts
204
- var registeredValues = {};
204
+ var registeredValues = {}, branchesEnabled;
205
+ function enableBranches() {
206
+ branchesEnabled = 1;
207
+ }
205
208
  function init(runtimeId = DEFAULT_RUNTIME_ID) {
206
209
  let renders = self[runtimeId], defineRuntime = (desc) => Object.defineProperty(self, runtimeId, desc), resumeRender, initRuntime = (renders2) => {
207
210
  defineRuntime({
@@ -226,25 +229,27 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
226
229
  if (token === "*" /* Node */) {
227
230
  let node = scope[data2] = visit.previousSibling;
228
231
  scope["j" /* Getter */ + data2] = () => node;
229
- } else if (token === "[" /* BranchStart */)
230
- currentBranchId && dataIndex && (branchEnd(currentBranchId, visit), currentBranchId = branchStack.pop()), currentBranchId && (branchStack.push(currentBranchId), parentBranchIds.set(scopeId, currentBranchId)), currentBranchId = scopeId, scope.h = visit;
231
- else if (token === "]" /* BranchEnd */) {
232
- scope[data2] = visit;
233
- let curParent = visit.parentNode, startNode = branchEnd(
234
- currentBranchId,
235
- visit
236
- ).h;
237
- curParent !== startNode.parentNode && curParent.prepend(startNode), currentBranchId = branchStack.pop();
238
- } else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
239
- let next = data2.indexOf(" "), curNode = visit;
240
- for (scope[~next ? data2.slice(0, next) : data2] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit; ~next; ) {
241
- let start = next + 1;
242
- next = data2.indexOf(" ", start);
243
- let childScopeId = +data2.slice(
244
- start,
245
- ~next ? next : data2.length
246
- );
247
- curNode = branchEnd(childScopeId, curNode).j, parentBranchIds.set(childScopeId, scopeId);
232
+ } else if (branchesEnabled) {
233
+ if (token === "[" /* BranchStart */)
234
+ currentBranchId && dataIndex && (branchEnd(currentBranchId, visit), currentBranchId = branchStack.pop()), currentBranchId && (branchStack.push(currentBranchId), parentBranchIds.set(scopeId, currentBranchId)), currentBranchId = scopeId, scope.h = visit;
235
+ else if (token === "]" /* BranchEnd */) {
236
+ scope[data2] = visit;
237
+ let curParent = visit.parentNode, startNode = branchEnd(
238
+ currentBranchId,
239
+ visit
240
+ ).h;
241
+ curParent !== startNode.parentNode && curParent.prepend(startNode), currentBranchId = branchStack.pop();
242
+ } else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
243
+ let next = data2.indexOf(" "), curNode = visit;
244
+ for (scope[~next ? data2.slice(0, next) : data2] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit; ~next; ) {
245
+ let start = next + 1;
246
+ next = data2.indexOf(" ", start);
247
+ let childScopeId = +data2.slice(
248
+ start,
249
+ ~next ? next : data2.length
250
+ );
251
+ curNode = branchEnd(childScopeId, curNode).j, parentBranchIds.set(childScopeId, scopeId);
252
+ }
248
253
  }
249
254
  }
250
255
  }
@@ -264,16 +269,17 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
264
269
  lastScopeId += scope;
265
270
  else {
266
271
  let scopeId = ++lastScopeId, prevScope = scopeLookup[scopeId];
267
- scope.$global = $global, scope.m = scopeId, prevScope !== scope && (scopeLookup[scopeId] = Object.assign(
272
+ if (scope.$global = $global, scope.m = scopeId, prevScope !== scope && (scopeLookup[scopeId] = Object.assign(
268
273
  scope,
269
274
  prevScope
270
- ));
271
- let parentBranchId = scope.g || parentBranchIds.get(scopeId);
272
- if (parentBranchId && (scope.k = scopeLookup[parentBranchId]), branchIds.has(scopeId)) {
273
- let branch = scope, parentBranch = branch.k;
274
- scope.k = branch, parentBranch && (branch.t = parentBranch, (parentBranch.z ||= /* @__PURE__ */ new Set()).add(
275
- branch
276
- ));
275
+ )), branchesEnabled) {
276
+ let parentBranchId = scope.g || parentBranchIds.get(scopeId);
277
+ if (parentBranchId && (scope.k = scopeLookup[parentBranchId]), branchIds.has(scopeId)) {
278
+ let branch = scope, parentBranch = branch.k;
279
+ scope.k = branch, parentBranch && (branch.t = parentBranch, (parentBranch.z ||= /* @__PURE__ */ new Set()).add(
280
+ branch
281
+ ));
282
+ }
277
283
  }
278
284
  }
279
285
  } finally {
@@ -1173,7 +1179,7 @@ function renderCatch(scope, error) {
1173
1179
  }
1174
1180
  function conditional(nodeAccessor, ...branches) {
1175
1181
  let branchAccessor = "c" /* ConditionalRenderer */ + nodeAccessor;
1176
- return (scope, newBranch) => {
1182
+ return enableBranches(), (scope, newBranch) => {
1177
1183
  newBranch !== scope[branchAccessor] && setConditionalRenderer(
1178
1184
  scope,
1179
1185
  nodeAccessor,
@@ -1187,7 +1193,7 @@ function patchDynamicTag(fn) {
1187
1193
  }
1188
1194
  var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
1189
1195
  let childScopeAccessor = "d" /* ConditionalScope */ + nodeAccessor, rendererAccessor = "c" /* ConditionalRenderer */ + nodeAccessor;
1190
- return (scope, newRenderer, getInput) => {
1196
+ return enableBranches(), (scope, newRenderer, getInput) => {
1191
1197
  let normalizedRenderer = normalizeDynamicRenderer(newRenderer);
1192
1198
  if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.m || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor]))
1193
1199
  if (setConditionalRenderer(
@@ -1270,7 +1276,7 @@ function loopTo(nodeAccessor, renderer) {
1270
1276
  }
1271
1277
  function loop(nodeAccessor, renderer, forEach) {
1272
1278
  let params = renderer.l;
1273
- return (scope, value2) => {
1279
+ return enableBranches(), (scope, value2) => {
1274
1280
  let referenceNode = scope[nodeAccessor], oldMap = scope["m" /* LoopScopeMap */ + nodeAccessor], oldArray = oldMap ? scope["l" /* LoopScopeArray */ + nodeAccessor] || [
1275
1281
  ...oldMap.values()
1276
1282
  ] : [], parentNode = referenceNode.nodeType > 1 /* Element */ ? referenceNode.parentNode || oldArray[0].h.parentNode : referenceNode, newMap = scope["m" /* LoopScopeMap */ + nodeAccessor] = /* @__PURE__ */ new Map(), newArray = scope["l" /* LoopScopeArray */ + nodeAccessor] = [];
@@ -1372,7 +1378,7 @@ function runRenders() {
1372
1378
  }
1373
1379
  var runRender = (render) => render.L(render.D, render.I), enableCatch = () => {
1374
1380
  enableCatch = () => {
1375
- };
1381
+ }, enableBranches();
1376
1382
  let handlePendingTry = (fn, scope, branch) => {
1377
1383
  for (; branch; ) {
1378
1384
  if (branch.n)
package/dist/dom.mjs CHANGED
@@ -112,7 +112,10 @@ function stripSpacesAndPunctuation(str) {
112
112
  var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
113
113
 
114
114
  // src/dom/resume.ts
115
- var registeredValues = {};
115
+ var registeredValues = {}, branchesEnabled;
116
+ function enableBranches() {
117
+ branchesEnabled = 1;
118
+ }
116
119
  function init(runtimeId = DEFAULT_RUNTIME_ID) {
117
120
  let renders = self[runtimeId], defineRuntime = (desc) => Object.defineProperty(self, runtimeId, desc), resumeRender, initRuntime = (renders2) => {
118
121
  defineRuntime({
@@ -137,25 +140,27 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
137
140
  if (token === "*" /* Node */) {
138
141
  let node = scope[data2] = visit.previousSibling;
139
142
  scope["j" /* Getter */ + data2] = () => node;
140
- } else if (token === "[" /* BranchStart */)
141
- currentBranchId && dataIndex && (branchEnd(currentBranchId, visit), currentBranchId = branchStack.pop()), currentBranchId && (branchStack.push(currentBranchId), parentBranchIds.set(scopeId, currentBranchId)), currentBranchId = scopeId, scope.h = visit;
142
- else if (token === "]" /* BranchEnd */) {
143
- scope[data2] = visit;
144
- let curParent = visit.parentNode, startNode = branchEnd(
145
- currentBranchId,
146
- visit
147
- ).h;
148
- curParent !== startNode.parentNode && curParent.prepend(startNode), currentBranchId = branchStack.pop();
149
- } else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
150
- let next = data2.indexOf(" "), curNode = visit;
151
- for (scope[~next ? data2.slice(0, next) : data2] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit; ~next; ) {
152
- let start = next + 1;
153
- next = data2.indexOf(" ", start);
154
- let childScopeId = +data2.slice(
155
- start,
156
- ~next ? next : data2.length
157
- );
158
- curNode = branchEnd(childScopeId, curNode).j, parentBranchIds.set(childScopeId, scopeId);
143
+ } else if (branchesEnabled) {
144
+ if (token === "[" /* BranchStart */)
145
+ currentBranchId && dataIndex && (branchEnd(currentBranchId, visit), currentBranchId = branchStack.pop()), currentBranchId && (branchStack.push(currentBranchId), parentBranchIds.set(scopeId, currentBranchId)), currentBranchId = scopeId, scope.h = visit;
146
+ else if (token === "]" /* BranchEnd */) {
147
+ scope[data2] = visit;
148
+ let curParent = visit.parentNode, startNode = branchEnd(
149
+ currentBranchId,
150
+ visit
151
+ ).h;
152
+ curParent !== startNode.parentNode && curParent.prepend(startNode), currentBranchId = branchStack.pop();
153
+ } else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
154
+ let next = data2.indexOf(" "), curNode = visit;
155
+ for (scope[~next ? data2.slice(0, next) : data2] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit; ~next; ) {
156
+ let start = next + 1;
157
+ next = data2.indexOf(" ", start);
158
+ let childScopeId = +data2.slice(
159
+ start,
160
+ ~next ? next : data2.length
161
+ );
162
+ curNode = branchEnd(childScopeId, curNode).j, parentBranchIds.set(childScopeId, scopeId);
163
+ }
159
164
  }
160
165
  }
161
166
  }
@@ -175,16 +180,17 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
175
180
  lastScopeId += scope;
176
181
  else {
177
182
  let scopeId = ++lastScopeId, prevScope = scopeLookup[scopeId];
178
- scope.$global = $global, scope.m = scopeId, prevScope !== scope && (scopeLookup[scopeId] = Object.assign(
183
+ if (scope.$global = $global, scope.m = scopeId, prevScope !== scope && (scopeLookup[scopeId] = Object.assign(
179
184
  scope,
180
185
  prevScope
181
- ));
182
- let parentBranchId = scope.g || parentBranchIds.get(scopeId);
183
- if (parentBranchId && (scope.k = scopeLookup[parentBranchId]), branchIds.has(scopeId)) {
184
- let branch = scope, parentBranch = branch.k;
185
- scope.k = branch, parentBranch && (branch.t = parentBranch, (parentBranch.z ||= /* @__PURE__ */ new Set()).add(
186
- branch
187
- ));
186
+ )), branchesEnabled) {
187
+ let parentBranchId = scope.g || parentBranchIds.get(scopeId);
188
+ if (parentBranchId && (scope.k = scopeLookup[parentBranchId]), branchIds.has(scopeId)) {
189
+ let branch = scope, parentBranch = branch.k;
190
+ scope.k = branch, parentBranch && (branch.t = parentBranch, (parentBranch.z ||= /* @__PURE__ */ new Set()).add(
191
+ branch
192
+ ));
193
+ }
188
194
  }
189
195
  }
190
196
  } finally {
@@ -1084,7 +1090,7 @@ function renderCatch(scope, error) {
1084
1090
  }
1085
1091
  function conditional(nodeAccessor, ...branches) {
1086
1092
  let branchAccessor = "c" /* ConditionalRenderer */ + nodeAccessor;
1087
- return (scope, newBranch) => {
1093
+ return enableBranches(), (scope, newBranch) => {
1088
1094
  newBranch !== scope[branchAccessor] && setConditionalRenderer(
1089
1095
  scope,
1090
1096
  nodeAccessor,
@@ -1098,7 +1104,7 @@ function patchDynamicTag(fn) {
1098
1104
  }
1099
1105
  var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
1100
1106
  let childScopeAccessor = "d" /* ConditionalScope */ + nodeAccessor, rendererAccessor = "c" /* ConditionalRenderer */ + nodeAccessor;
1101
- return (scope, newRenderer, getInput) => {
1107
+ return enableBranches(), (scope, newRenderer, getInput) => {
1102
1108
  let normalizedRenderer = normalizeDynamicRenderer(newRenderer);
1103
1109
  if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.m || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor]))
1104
1110
  if (setConditionalRenderer(
@@ -1181,7 +1187,7 @@ function loopTo(nodeAccessor, renderer) {
1181
1187
  }
1182
1188
  function loop(nodeAccessor, renderer, forEach) {
1183
1189
  let params = renderer.l;
1184
- return (scope, value2) => {
1190
+ return enableBranches(), (scope, value2) => {
1185
1191
  let referenceNode = scope[nodeAccessor], oldMap = scope["m" /* LoopScopeMap */ + nodeAccessor], oldArray = oldMap ? scope["l" /* LoopScopeArray */ + nodeAccessor] || [
1186
1192
  ...oldMap.values()
1187
1193
  ] : [], parentNode = referenceNode.nodeType > 1 /* Element */ ? referenceNode.parentNode || oldArray[0].h.parentNode : referenceNode, newMap = scope["m" /* LoopScopeMap */ + nodeAccessor] = /* @__PURE__ */ new Map(), newArray = scope["l" /* LoopScopeArray */ + nodeAccessor] = [];
@@ -1283,7 +1289,7 @@ function runRenders() {
1283
1289
  }
1284
1290
  var runRender = (render) => render.L(render.D, render.I), enableCatch = () => {
1285
1291
  enableCatch = () => {
1286
- };
1292
+ }, enableBranches();
1287
1293
  let handlePendingTry = (fn, scope, branch) => {
1288
1294
  for (; branch; ) {
1289
1295
  if (branch.n)
@@ -35,14 +35,14 @@ export declare function hoist(scopeId: number, id?: string): {
35
35
  };
36
36
  export declare function resumeClosestBranch(scopeId: number): void;
37
37
  export declare function withBranchId<T>(branchId: number, cb: () => T): T;
38
- export declare function resumeForOf(list: Falsy | Iterable<unknown>, cb: (item: unknown, index: number) => void, by: Falsy | ((item: unknown, index: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1): void;
39
- export declare function resumeSingleNodeForOf(list: Falsy | Iterable<unknown>, cb: (item: unknown, index: number) => void, by: Falsy | ((item: unknown, index: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, onlyChildInParent?: 1): void;
40
- export declare function resumeForIn(obj: Falsy | {}, cb: (key: string, value: unknown) => void, by: Falsy | ((key: string, v: unknown) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1): void;
41
- export declare function resumeSingleNodeForIn(obj: Falsy | {}, cb: (key: string, value: unknown) => void, by: Falsy | ((key: string, v: unknown) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, onlyChildInParent?: 1): void;
42
- export declare function resumeForTo(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void, by: Falsy | ((v: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1): void;
43
- export declare function resumeSingleNodeForTo(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void, by: Falsy | ((v: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, onlyChildInParent?: 1): void;
44
- export declare function resumeConditional(cb: () => void | number, scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1): void;
45
- export declare function resumeSingleNodeConditional(cb: () => void | number, scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, onlyChildInParent?: 1): void;
38
+ export declare function resumeForOf(list: Falsy | Iterable<unknown>, cb: (item: unknown, index: number) => void, by: Falsy | ((item: unknown, index: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, parentEndTag?: string): void;
39
+ export declare function resumeSingleNodeForOf(list: Falsy | Iterable<unknown>, cb: (item: unknown, index: number) => void, by: Falsy | ((item: unknown, index: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, parentEndTag?: string): void;
40
+ export declare function resumeForIn(obj: Falsy | {}, cb: (key: string, value: unknown) => void, by: Falsy | ((key: string, v: unknown) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, parentEndTag?: string): void;
41
+ export declare function resumeSingleNodeForIn(obj: Falsy | {}, cb: (key: string, value: unknown) => void, by: Falsy | ((key: string, v: unknown) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, parentEndTag?: string): void;
42
+ export declare function resumeForTo(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void, by: Falsy | ((v: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, parentEndTag?: string): void;
43
+ export declare function resumeSingleNodeForTo(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void, by: Falsy | ((v: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, parentEndTag?: string): void;
44
+ export declare function resumeConditional(cb: () => void | number, scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, parentEndTag?: string): void;
45
+ export declare function resumeSingleNodeConditional(cb: () => void | number, scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, parentEndTag?: string): void;
46
46
  declare let writeScope: (scopeId: number, partialScope: PartialScope) => ScopeInternals;
47
47
  export { writeScope };
48
48
  export declare function writeExistingScope(scopeId: number): ScopeInternals;