marko 6.0.0-next.3.23 → 6.0.0-next.3.25

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.
package/dist/debug/dom.js CHANGED
@@ -485,7 +485,7 @@ function handleDelegated(ev) {
485
485
  const handlersByElement = elementHandlersByEvent.get(ev.type);
486
486
  handlersByElement.get(target)?.(ev, target);
487
487
  if (ev.bubbles) {
488
- while ((target = target.parentElement) && !ev.cancelBubble) {
488
+ while ((target = target.parentNode) && !ev.cancelBubble) {
489
489
  handlersByElement.get(target)?.(ev, target);
490
490
  }
491
491
  }
@@ -1006,18 +1006,26 @@ function toValueProp(it) {
1006
1006
  }
1007
1007
 
1008
1008
  // src/dom/parse-html.ts
1009
- var fallback = /* @__PURE__ */ document.createTextNode("");
1010
- var parser = /* @__PURE__ */ new Range();
1009
+ var fallback = /* @__PURE__ */ new Text();
1010
+ var parser = /* @__PURE__ */ document.createElement("template");
1011
1011
  function parseHTML(html2) {
1012
- return parser.createContextualFragment(html2);
1012
+ parser.innerHTML = html2;
1013
+ return parser.content;
1013
1014
  }
1014
1015
  function parseHTMLOrSingleNode(html2) {
1015
1016
  const content = parseHTML(html2);
1016
- if (!content.firstChild) return fallback;
1017
- return content.firstChild === content.lastChild && // If the firstChild is a comment it's possible its
1018
- // a single replaced node, in which case the walker can't replace
1019
- // the node itself.
1020
- content.firstChild.nodeType !== 8 ? content.firstChild : content;
1017
+ if (content.firstChild) {
1018
+ if (content.firstChild === content.lastChild && // If the firstChild is a comment it's possible its
1019
+ // a single replaced node, in which case the walker can't replace
1020
+ // the node itself.
1021
+ content.firstChild.nodeType !== 8) {
1022
+ return content.firstChild;
1023
+ }
1024
+ const fragment = new DocumentFragment();
1025
+ fragment.appendChild(content);
1026
+ return fragment;
1027
+ }
1028
+ return fallback;
1021
1029
  }
1022
1030
 
1023
1031
  // src/dom/dom.ts
@@ -1294,7 +1302,7 @@ function walkInternal(walkCodes, scope, currentWalkIndex) {
1294
1302
  } else if (value2 === 32 /* Get */) {
1295
1303
  scope[true ? getDebugKey(currentScopeIndex++, walker.currentNode) : currentScopeIndex++] = walker.currentNode;
1296
1304
  } else {
1297
- const newNode = scope[true ? getDebugKey(currentScopeIndex++, "#text") : currentScopeIndex++] = document.createTextNode("");
1305
+ const newNode = scope[true ? getDebugKey(currentScopeIndex++, "#text") : currentScopeIndex++] = new Text();
1298
1306
  const current = walker.currentNode;
1299
1307
  const parentNode = current.parentNode;
1300
1308
  if (value2 !== 37 /* Replace */) {
@@ -1884,6 +1892,7 @@ function runRenders() {
1884
1892
  finishPendingScopes();
1885
1893
  }
1886
1894
  function comparePendingRenders(a, b) {
1895
+ if (a.___scope.___pending || b.___scope.___pending) return 0;
1887
1896
  const aStart = ownerStartNode(a.___scope);
1888
1897
  const bStart = ownerStartNode(b.___scope);
1889
1898
  return aStart === bStart ? 0 : aStart ? bStart ? aStart.compareDocumentPosition(bStart) & 2 ? -1 : 1 : -1 : 1;
@@ -2042,14 +2051,14 @@ function mount(input = {}, reference, position) {
2042
2051
  }
2043
2052
  });
2044
2053
  switch (position) {
2054
+ case "beforebegin":
2055
+ reference.parentNode.insertBefore(dom, reference);
2056
+ break;
2045
2057
  case "afterbegin":
2046
2058
  reference.insertBefore(dom, reference.firstChild);
2047
2059
  break;
2048
2060
  case "afterend":
2049
- reference.parentElement.insertBefore(dom, reference.nextSibling);
2050
- break;
2051
- case "beforebegin":
2052
- reference.parentElement.insertBefore(dom, reference);
2061
+ reference.parentNode.insertBefore(dom, reference.nextSibling);
2053
2062
  break;
2054
2063
  default:
2055
2064
  reference.appendChild(dom);
@@ -398,7 +398,7 @@ function handleDelegated(ev) {
398
398
  const handlersByElement = elementHandlersByEvent.get(ev.type);
399
399
  handlersByElement.get(target)?.(ev, target);
400
400
  if (ev.bubbles) {
401
- while ((target = target.parentElement) && !ev.cancelBubble) {
401
+ while ((target = target.parentNode) && !ev.cancelBubble) {
402
402
  handlersByElement.get(target)?.(ev, target);
403
403
  }
404
404
  }
@@ -919,18 +919,26 @@ function toValueProp(it) {
919
919
  }
920
920
 
921
921
  // src/dom/parse-html.ts
922
- var fallback = /* @__PURE__ */ document.createTextNode("");
923
- var parser = /* @__PURE__ */ new Range();
922
+ var fallback = /* @__PURE__ */ new Text();
923
+ var parser = /* @__PURE__ */ document.createElement("template");
924
924
  function parseHTML(html2) {
925
- return parser.createContextualFragment(html2);
925
+ parser.innerHTML = html2;
926
+ return parser.content;
926
927
  }
927
928
  function parseHTMLOrSingleNode(html2) {
928
929
  const content = parseHTML(html2);
929
- if (!content.firstChild) return fallback;
930
- return content.firstChild === content.lastChild && // If the firstChild is a comment it's possible its
931
- // a single replaced node, in which case the walker can't replace
932
- // the node itself.
933
- content.firstChild.nodeType !== 8 ? content.firstChild : content;
930
+ if (content.firstChild) {
931
+ if (content.firstChild === content.lastChild && // If the firstChild is a comment it's possible its
932
+ // a single replaced node, in which case the walker can't replace
933
+ // the node itself.
934
+ content.firstChild.nodeType !== 8) {
935
+ return content.firstChild;
936
+ }
937
+ const fragment = new DocumentFragment();
938
+ fragment.appendChild(content);
939
+ return fragment;
940
+ }
941
+ return fallback;
934
942
  }
935
943
 
936
944
  // src/dom/dom.ts
@@ -1207,7 +1215,7 @@ function walkInternal(walkCodes, scope, currentWalkIndex) {
1207
1215
  } else if (value2 === 32 /* Get */) {
1208
1216
  scope[true ? getDebugKey(currentScopeIndex++, walker.currentNode) : currentScopeIndex++] = walker.currentNode;
1209
1217
  } else {
1210
- const newNode = scope[true ? getDebugKey(currentScopeIndex++, "#text") : currentScopeIndex++] = document.createTextNode("");
1218
+ const newNode = scope[true ? getDebugKey(currentScopeIndex++, "#text") : currentScopeIndex++] = new Text();
1211
1219
  const current = walker.currentNode;
1212
1220
  const parentNode = current.parentNode;
1213
1221
  if (value2 !== 37 /* Replace */) {
@@ -1797,6 +1805,7 @@ function runRenders() {
1797
1805
  finishPendingScopes();
1798
1806
  }
1799
1807
  function comparePendingRenders(a, b) {
1808
+ if (a.___scope.___pending || b.___scope.___pending) return 0;
1800
1809
  const aStart = ownerStartNode(a.___scope);
1801
1810
  const bStart = ownerStartNode(b.___scope);
1802
1811
  return aStart === bStart ? 0 : aStart ? bStart ? aStart.compareDocumentPosition(bStart) & 2 ? -1 : 1 : -1 : 1;
@@ -1955,14 +1964,14 @@ function mount(input = {}, reference, position) {
1955
1964
  }
1956
1965
  });
1957
1966
  switch (position) {
1967
+ case "beforebegin":
1968
+ reference.parentNode.insertBefore(dom, reference);
1969
+ break;
1958
1970
  case "afterbegin":
1959
1971
  reference.insertBefore(dom, reference.firstChild);
1960
1972
  break;
1961
1973
  case "afterend":
1962
- reference.parentElement.insertBefore(dom, reference.nextSibling);
1963
- break;
1964
- case "beforebegin":
1965
- reference.parentElement.insertBefore(dom, reference);
1974
+ reference.parentNode.insertBefore(dom, reference.nextSibling);
1966
1975
  break;
1967
1976
  default:
1968
1977
  reference.appendChild(dom);
@@ -1,5 +1,2 @@
1
1
  export declare function parseHTML(html: string): DocumentFragment;
2
- export declare function parseHTMLOrSingleNode(html: string): Text | (Node & {
3
- firstChild?: ChildNode;
4
- lastChild?: ChildNode;
5
- });
2
+ export declare function parseHTMLOrSingleNode(html: string): ChildNode | DocumentFragment;
package/dist/dom.js CHANGED
@@ -133,14 +133,14 @@ function triggerMacroTask() {
133
133
  var pendingScopes = [];
134
134
  function createScope($global) {
135
135
  let scope = {
136
- g: 1,
136
+ e: 1,
137
137
  $global
138
138
  };
139
139
  return pendingScopes.push(scope), scope;
140
140
  }
141
141
  function finishPendingScopes() {
142
142
  for (let scope of pendingScopes)
143
- scope.g = 0;
143
+ scope.e = 0;
144
144
  pendingScopes = [];
145
145
  }
146
146
  var emptyScope = createScope({});
@@ -150,8 +150,8 @@ function getEmptyScope(marker) {
150
150
  function destroyBranch(branch) {
151
151
  if (branch.y = 1, branch.m?.forEach(destroyBranch), branch.n)
152
152
  for (let scope of branch.n)
153
- for (let id in scope.h)
154
- scope.h[id]?.abort();
153
+ for (let id in scope.j)
154
+ scope.j[id]?.abort();
155
155
  }
156
156
  function removeAndDestroyBranch(branch) {
157
157
  destroyBranch(branch);
@@ -310,7 +310,7 @@ function handleDelegated(ev) {
310
310
  if (target) {
311
311
  let handlersByElement = elementHandlersByEvent.get(ev.type);
312
312
  if (handlersByElement.get(target)?.(ev, target), ev.bubbles)
313
- for (; (target = target.parentElement) && !ev.cancelBubble; )
313
+ for (; (target = target.parentNode) && !ev.cancelBubble; )
314
314
  handlersByElement.get(target)?.(ev, target);
315
315
  }
316
316
  }
@@ -376,15 +376,15 @@ var registeredValues = {}, Render = class {
376
376
  else if (token === "$" /* ClosestBranch */)
377
377
  closestBranchMarkers.set(scopeId, visit);
378
378
  else if (token === "[" /* BranchStart */)
379
- this.f && (dataIndex && branchEnd(this.f, visit, visit), this.o.push(this.f)), this.f = scopeId, scope.a = visit;
379
+ this.h && (dataIndex && branchEnd(this.h, visit, visit), this.o.push(this.h)), this.h = scopeId, scope.a = visit;
380
380
  else if (token === "]" /* BranchEnd */) {
381
381
  scope[data3] = visit;
382
382
  let curParent = visit.parentNode, startNode = branchEnd(
383
- this.f,
383
+ this.h,
384
384
  visit,
385
385
  visit
386
386
  ).a;
387
- curParent !== startNode.parentNode && curParent.prepend(startNode), this.f = this.o.pop();
387
+ curParent !== startNode.parentNode && curParent.prepend(startNode), this.h = this.o.pop();
388
388
  } else if (token === "|" /* BranchSingleNode */) {
389
389
  let next = data3.indexOf(" "), curNode = scope[~next ? data3.slice(0, next) : data3] = visit;
390
390
  for (; ~next; ) {
@@ -636,16 +636,22 @@ function toValueProp(it) {
636
636
  }
637
637
 
638
638
  // src/dom/parse-html.ts
639
- var fallback = /* @__PURE__ */ document.createTextNode(""), parser = /* @__PURE__ */ new Range();
639
+ var fallback = /* @__PURE__ */ new Text(), parser = /* @__PURE__ */ document.createElement("template");
640
640
  function parseHTML(html2) {
641
- return parser.createContextualFragment(html2);
641
+ return parser.innerHTML = html2, parser.content;
642
642
  }
643
643
  function parseHTMLOrSingleNode(html2) {
644
644
  let content = parseHTML(html2);
645
- return content.firstChild ? content.firstChild === content.lastChild && // If the firstChild is a comment it's possible its
646
- // a single replaced node, in which case the walker can't replace
647
- // the node itself.
648
- content.firstChild.nodeType !== 8 ? content.firstChild : content : fallback;
645
+ if (content.firstChild) {
646
+ if (content.firstChild === content.lastChild && // If the firstChild is a comment it's possible its
647
+ // a single replaced node, in which case the walker can't replace
648
+ // the node itself.
649
+ content.firstChild.nodeType !== 8)
650
+ return content.firstChild;
651
+ let fragment = new DocumentFragment();
652
+ return fragment.appendChild(content), fragment;
653
+ }
654
+ return fallback;
649
655
  }
650
656
 
651
657
  // src/dom/dom.ts
@@ -851,7 +857,7 @@ function walkInternal(walkCodes, scope, currentWalkIndex) {
851
857
  if (value2 === 32 /* Get */)
852
858
  scope[currentScopeIndex++] = walker.currentNode;
853
859
  else {
854
- let newNode = scope[currentScopeIndex++] = document.createTextNode(""), current = walker.currentNode;
860
+ let newNode = scope[currentScopeIndex++] = new Text(), current = walker.currentNode;
855
861
  current.parentNode.replaceChild(newNode, current), walker.currentNode = newNode;
856
862
  }
857
863
  }
@@ -896,13 +902,13 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
896
902
  return;
897
903
  let childScope = scope[nodeAccessor + "!" /* ConditionalScope */];
898
904
  if (attrsOrOp === MARK || attrsOrOp === CLEAN)
899
- return renderer.e?.(childScope, attrsOrOp);
905
+ return renderer.f?.(childScope, attrsOrOp);
900
906
  let content = getContent?.(scope);
901
907
  if (typeof renderer == "string")
902
908
  setConditionalRendererOnlyChild(childScope, 0, content), attrs(childScope, 0, attrsOrOp());
903
- else if (renderer.e) {
909
+ else if (renderer.f) {
904
910
  let attributes = attrsOrOp();
905
- renderer.e(
911
+ renderer.f(
906
912
  childScope,
907
913
  inputIsArgs ? attributes : [
908
914
  content ? {
@@ -917,14 +923,14 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
917
923
  function createRendererWithOwner(template, rawWalks, setup, getArgs) {
918
924
  let args, id = {}, walks = rawWalks ? /* @__PURE__ */ trimWalkString(rawWalks) : " ";
919
925
  return (owner) => ({
920
- j: id,
926
+ k: id,
921
927
  F: template,
922
928
  E: walks,
923
929
  x: setup,
924
930
  l: _clone,
925
931
  u: owner,
926
932
  G: void 0,
927
- get e() {
933
+ get f() {
928
934
  return args ||= getArgs?.();
929
935
  }
930
936
  });
@@ -1014,7 +1020,7 @@ function loopTo(nodeAccessor, renderer) {
1014
1020
  );
1015
1021
  }
1016
1022
  function loop(nodeAccessor, renderer, forEach) {
1017
- let loopScopeAccessor = nodeAccessor + "!" /* LoopScopeArray */, params = renderer.e;
1023
+ let loopScopeAccessor = nodeAccessor + "!" /* LoopScopeArray */, params = renderer.f;
1018
1024
  return (scope, valueOrOp) => {
1019
1025
  if (valueOrOp === DIRTY) return;
1020
1026
  if (valueOrOp === MARK || valueOrOp === CLEAN) {
@@ -1047,7 +1053,7 @@ function byFirstArg(name) {
1047
1053
  return name;
1048
1054
  }
1049
1055
  function isDifferentRenderer(a, b) {
1050
- return a !== b && (a?.j || 0) !== b?.j;
1056
+ return a !== b && (a?.k || 0) !== b?.k;
1051
1057
  }
1052
1058
 
1053
1059
  // src/dom/signals.ts
@@ -1088,14 +1094,14 @@ function loopClosure(ownerLoopNodeAccessor, fn, getIntersection) {
1088
1094
  let loopScopes = ownerScope[loopScopeAccessor] ?? ownerScope[loopScopeMapAccessor]?.values() ?? [];
1089
1095
  if (loopScopes !== emptyMarkerArray)
1090
1096
  for (let scope of loopScopes)
1091
- scope.g || queueSource(scope, signal, value2);
1097
+ scope.e || queueSource(scope, signal, value2);
1092
1098
  };
1093
1099
  return helperSignal._ = signal, helperSignal;
1094
1100
  }
1095
1101
  function conditionalClosure(ownerConditionalNodeAccessor, getRenderer, fn, getIntersection) {
1096
1102
  let signal = closure(fn, getIntersection), scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */, rendererAccessor = ownerConditionalNodeAccessor + "(" /* ConditionalRenderer */, helperSignal = (scope, value2) => {
1097
1103
  let conditionalScope = scope[scopeAccessor];
1098
- conditionalScope && !conditionalScope.g && scope[rendererAccessor]?.j === getRenderer().j && queueSource(conditionalScope, signal, value2);
1104
+ conditionalScope && !conditionalScope.e && scope[rendererAccessor]?.k === getRenderer().k && queueSource(conditionalScope, signal, value2);
1099
1105
  };
1100
1106
  return helperSignal._ = signal, helperSignal;
1101
1107
  }
@@ -1105,7 +1111,7 @@ function dynamicClosure(ownerValueAccessor, fn, getOwnerScope = defaultGetOwnerS
1105
1111
  let subscribers = ownerScope[ownerSubscribersAccessor];
1106
1112
  if (subscribers)
1107
1113
  for (let subscriber of subscribers)
1108
- subscriber.g || queueSource(subscriber, _signal, value2);
1114
+ subscriber.e || queueSource(subscriber, _signal, value2);
1109
1115
  }, setupSignal = (scope, value2) => {
1110
1116
  _signal(scope, value2), subscribe(scope);
1111
1117
  }, subscribe = (scope) => {
@@ -1154,7 +1160,7 @@ function queueSource(scope, signal, value2) {
1154
1160
  }
1155
1161
  function queueRender(scope, signal, value2) {
1156
1162
  let nextRender = {
1157
- k: scope,
1163
+ g: scope,
1158
1164
  H: signal,
1159
1165
  I: value2,
1160
1166
  d: void 0
@@ -1200,11 +1206,12 @@ function runEffects(effects = pendingEffects) {
1200
1206
  }
1201
1207
  function runRenders() {
1202
1208
  for (; pendingRender; )
1203
- pendingRender.k.b?.y || pendingRender.H(pendingRender.k, pendingRender.I), pendingRender = pendingRender.d;
1209
+ pendingRender.g.b?.y || pendingRender.H(pendingRender.g, pendingRender.I), pendingRender = pendingRender.d;
1204
1210
  finishPendingScopes();
1205
1211
  }
1206
1212
  function comparePendingRenders(a, b) {
1207
- let aStart = ownerStartNode(a.k), bStart = ownerStartNode(b.k);
1213
+ if (a.g.e || b.g.e) return 0;
1214
+ let aStart = ownerStartNode(a.g), bStart = ownerStartNode(b.g);
1208
1215
  return aStart === bStart ? 0 : aStart ? bStart ? aStart.compareDocumentPosition(bStart) & 2 ? -1 : 1 : -1 : 1;
1209
1216
  }
1210
1217
  function ownerStartNode(scope) {
@@ -1213,11 +1220,11 @@ function ownerStartNode(scope) {
1213
1220
 
1214
1221
  // src/dom/abort-signal.ts
1215
1222
  function resetAbortSignal(scope, id) {
1216
- let ctrl = scope.h?.[id];
1217
- ctrl && (queueEffect(ctrl, abort), scope.h[id] = void 0);
1223
+ let ctrl = scope.j?.[id];
1224
+ ctrl && (queueEffect(ctrl, abort), scope.j[id] = void 0);
1218
1225
  }
1219
1226
  function getAbortSignal(scope, id) {
1220
- return scope.b && (scope.b.n ||= /* @__PURE__ */ new Set()).add(scope), ((scope.h ||= {})[id] ||= new AbortController()).signal;
1227
+ return scope.b && (scope.b.n ||= /* @__PURE__ */ new Set()).add(scope), ((scope.j ||= {})[id] ||= new AbortController()).signal;
1221
1228
  }
1222
1229
  function abort(ctrl) {
1223
1230
  ctrl.abort();
@@ -1272,7 +1279,7 @@ var classIdToScope = /* @__PURE__ */ new Map(), compat = {
1272
1279
  render(out, component, renderer, args) {
1273
1280
  let scope = component.scope;
1274
1281
  scope || (scope = classIdToScope.get(component.id), scope && (component.scope = scope, classIdToScope.delete(component.id)));
1275
- let applyArgs = renderer.e || noop, existing = !1;
1282
+ let applyArgs = renderer.f || noop, existing = !1;
1276
1283
  if (typeof args[0] == "object" && "renderBody" in args[0]) {
1277
1284
  let input = args[0], normalizedInput = args[0] = {};
1278
1285
  for (let key in input)
@@ -1302,18 +1309,18 @@ function mount(input = {}, reference, position) {
1302
1309
  runtimeId: DEFAULT_RUNTIME_ID,
1303
1310
  renderId: DEFAULT_RENDER_ID
1304
1311
  };
1305
- let args = this.e, effects = prepareEffects(() => {
1312
+ let args = this.f, effects = prepareEffects(() => {
1306
1313
  branch = createScope($global), dom = initRenderer(this, branch), args && args(branch, [input]);
1307
1314
  });
1308
1315
  switch (position) {
1316
+ case "beforebegin":
1317
+ reference.parentNode.insertBefore(dom, reference);
1318
+ break;
1309
1319
  case "afterbegin":
1310
1320
  reference.insertBefore(dom, reference.firstChild);
1311
1321
  break;
1312
1322
  case "afterend":
1313
- reference.parentElement.insertBefore(dom, reference.nextSibling);
1314
- break;
1315
- case "beforebegin":
1316
- reference.parentElement.insertBefore(dom, reference);
1323
+ reference.parentNode.insertBefore(dom, reference.nextSibling);
1317
1324
  break;
1318
1325
  default:
1319
1326
  reference.appendChild(dom);
package/dist/dom.mjs CHANGED
@@ -49,14 +49,14 @@ function triggerMacroTask() {
49
49
  var pendingScopes = [];
50
50
  function createScope($global) {
51
51
  let scope = {
52
- g: 1,
52
+ e: 1,
53
53
  $global
54
54
  };
55
55
  return pendingScopes.push(scope), scope;
56
56
  }
57
57
  function finishPendingScopes() {
58
58
  for (let scope of pendingScopes)
59
- scope.g = 0;
59
+ scope.e = 0;
60
60
  pendingScopes = [];
61
61
  }
62
62
  var emptyScope = createScope({});
@@ -66,8 +66,8 @@ function getEmptyScope(marker) {
66
66
  function destroyBranch(branch) {
67
67
  if (branch.y = 1, branch.m?.forEach(destroyBranch), branch.n)
68
68
  for (let scope of branch.n)
69
- for (let id in scope.h)
70
- scope.h[id]?.abort();
69
+ for (let id in scope.j)
70
+ scope.j[id]?.abort();
71
71
  }
72
72
  function removeAndDestroyBranch(branch) {
73
73
  destroyBranch(branch);
@@ -226,7 +226,7 @@ function handleDelegated(ev) {
226
226
  if (target) {
227
227
  let handlersByElement = elementHandlersByEvent.get(ev.type);
228
228
  if (handlersByElement.get(target)?.(ev, target), ev.bubbles)
229
- for (; (target = target.parentElement) && !ev.cancelBubble; )
229
+ for (; (target = target.parentNode) && !ev.cancelBubble; )
230
230
  handlersByElement.get(target)?.(ev, target);
231
231
  }
232
232
  }
@@ -292,15 +292,15 @@ var registeredValues = {}, Render = class {
292
292
  else if (token === "$" /* ClosestBranch */)
293
293
  closestBranchMarkers.set(scopeId, visit);
294
294
  else if (token === "[" /* BranchStart */)
295
- this.f && (dataIndex && branchEnd(this.f, visit, visit), this.o.push(this.f)), this.f = scopeId, scope.a = visit;
295
+ this.h && (dataIndex && branchEnd(this.h, visit, visit), this.o.push(this.h)), this.h = scopeId, scope.a = visit;
296
296
  else if (token === "]" /* BranchEnd */) {
297
297
  scope[data3] = visit;
298
298
  let curParent = visit.parentNode, startNode = branchEnd(
299
- this.f,
299
+ this.h,
300
300
  visit,
301
301
  visit
302
302
  ).a;
303
- curParent !== startNode.parentNode && curParent.prepend(startNode), this.f = this.o.pop();
303
+ curParent !== startNode.parentNode && curParent.prepend(startNode), this.h = this.o.pop();
304
304
  } else if (token === "|" /* BranchSingleNode */) {
305
305
  let next = data3.indexOf(" "), curNode = scope[~next ? data3.slice(0, next) : data3] = visit;
306
306
  for (; ~next; ) {
@@ -552,16 +552,22 @@ function toValueProp(it) {
552
552
  }
553
553
 
554
554
  // src/dom/parse-html.ts
555
- var fallback = /* @__PURE__ */ document.createTextNode(""), parser = /* @__PURE__ */ new Range();
555
+ var fallback = /* @__PURE__ */ new Text(), parser = /* @__PURE__ */ document.createElement("template");
556
556
  function parseHTML(html2) {
557
- return parser.createContextualFragment(html2);
557
+ return parser.innerHTML = html2, parser.content;
558
558
  }
559
559
  function parseHTMLOrSingleNode(html2) {
560
560
  let content = parseHTML(html2);
561
- return content.firstChild ? content.firstChild === content.lastChild && // If the firstChild is a comment it's possible its
562
- // a single replaced node, in which case the walker can't replace
563
- // the node itself.
564
- content.firstChild.nodeType !== 8 ? content.firstChild : content : fallback;
561
+ if (content.firstChild) {
562
+ if (content.firstChild === content.lastChild && // If the firstChild is a comment it's possible its
563
+ // a single replaced node, in which case the walker can't replace
564
+ // the node itself.
565
+ content.firstChild.nodeType !== 8)
566
+ return content.firstChild;
567
+ let fragment = new DocumentFragment();
568
+ return fragment.appendChild(content), fragment;
569
+ }
570
+ return fallback;
565
571
  }
566
572
 
567
573
  // src/dom/dom.ts
@@ -767,7 +773,7 @@ function walkInternal(walkCodes, scope, currentWalkIndex) {
767
773
  if (value2 === 32 /* Get */)
768
774
  scope[currentScopeIndex++] = walker.currentNode;
769
775
  else {
770
- let newNode = scope[currentScopeIndex++] = document.createTextNode(""), current = walker.currentNode;
776
+ let newNode = scope[currentScopeIndex++] = new Text(), current = walker.currentNode;
771
777
  current.parentNode.replaceChild(newNode, current), walker.currentNode = newNode;
772
778
  }
773
779
  }
@@ -812,13 +818,13 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
812
818
  return;
813
819
  let childScope = scope[nodeAccessor + "!" /* ConditionalScope */];
814
820
  if (attrsOrOp === MARK || attrsOrOp === CLEAN)
815
- return renderer.e?.(childScope, attrsOrOp);
821
+ return renderer.f?.(childScope, attrsOrOp);
816
822
  let content = getContent?.(scope);
817
823
  if (typeof renderer == "string")
818
824
  setConditionalRendererOnlyChild(childScope, 0, content), attrs(childScope, 0, attrsOrOp());
819
- else if (renderer.e) {
825
+ else if (renderer.f) {
820
826
  let attributes = attrsOrOp();
821
- renderer.e(
827
+ renderer.f(
822
828
  childScope,
823
829
  inputIsArgs ? attributes : [
824
830
  content ? {
@@ -833,14 +839,14 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
833
839
  function createRendererWithOwner(template, rawWalks, setup, getArgs) {
834
840
  let args, id = {}, walks = rawWalks ? /* @__PURE__ */ trimWalkString(rawWalks) : " ";
835
841
  return (owner) => ({
836
- j: id,
842
+ k: id,
837
843
  F: template,
838
844
  E: walks,
839
845
  x: setup,
840
846
  l: _clone,
841
847
  u: owner,
842
848
  G: void 0,
843
- get e() {
849
+ get f() {
844
850
  return args ||= getArgs?.();
845
851
  }
846
852
  });
@@ -930,7 +936,7 @@ function loopTo(nodeAccessor, renderer) {
930
936
  );
931
937
  }
932
938
  function loop(nodeAccessor, renderer, forEach) {
933
- let loopScopeAccessor = nodeAccessor + "!" /* LoopScopeArray */, params = renderer.e;
939
+ let loopScopeAccessor = nodeAccessor + "!" /* LoopScopeArray */, params = renderer.f;
934
940
  return (scope, valueOrOp) => {
935
941
  if (valueOrOp === DIRTY) return;
936
942
  if (valueOrOp === MARK || valueOrOp === CLEAN) {
@@ -963,7 +969,7 @@ function byFirstArg(name) {
963
969
  return name;
964
970
  }
965
971
  function isDifferentRenderer(a, b) {
966
- return a !== b && (a?.j || 0) !== b?.j;
972
+ return a !== b && (a?.k || 0) !== b?.k;
967
973
  }
968
974
 
969
975
  // src/dom/signals.ts
@@ -1004,14 +1010,14 @@ function loopClosure(ownerLoopNodeAccessor, fn, getIntersection) {
1004
1010
  let loopScopes = ownerScope[loopScopeAccessor] ?? ownerScope[loopScopeMapAccessor]?.values() ?? [];
1005
1011
  if (loopScopes !== emptyMarkerArray)
1006
1012
  for (let scope of loopScopes)
1007
- scope.g || queueSource(scope, signal, value2);
1013
+ scope.e || queueSource(scope, signal, value2);
1008
1014
  };
1009
1015
  return helperSignal._ = signal, helperSignal;
1010
1016
  }
1011
1017
  function conditionalClosure(ownerConditionalNodeAccessor, getRenderer, fn, getIntersection) {
1012
1018
  let signal = closure(fn, getIntersection), scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */, rendererAccessor = ownerConditionalNodeAccessor + "(" /* ConditionalRenderer */, helperSignal = (scope, value2) => {
1013
1019
  let conditionalScope = scope[scopeAccessor];
1014
- conditionalScope && !conditionalScope.g && scope[rendererAccessor]?.j === getRenderer().j && queueSource(conditionalScope, signal, value2);
1020
+ conditionalScope && !conditionalScope.e && scope[rendererAccessor]?.k === getRenderer().k && queueSource(conditionalScope, signal, value2);
1015
1021
  };
1016
1022
  return helperSignal._ = signal, helperSignal;
1017
1023
  }
@@ -1021,7 +1027,7 @@ function dynamicClosure(ownerValueAccessor, fn, getOwnerScope = defaultGetOwnerS
1021
1027
  let subscribers = ownerScope[ownerSubscribersAccessor];
1022
1028
  if (subscribers)
1023
1029
  for (let subscriber of subscribers)
1024
- subscriber.g || queueSource(subscriber, _signal, value2);
1030
+ subscriber.e || queueSource(subscriber, _signal, value2);
1025
1031
  }, setupSignal = (scope, value2) => {
1026
1032
  _signal(scope, value2), subscribe(scope);
1027
1033
  }, subscribe = (scope) => {
@@ -1070,7 +1076,7 @@ function queueSource(scope, signal, value2) {
1070
1076
  }
1071
1077
  function queueRender(scope, signal, value2) {
1072
1078
  let nextRender = {
1073
- k: scope,
1079
+ g: scope,
1074
1080
  H: signal,
1075
1081
  I: value2,
1076
1082
  d: void 0
@@ -1116,11 +1122,12 @@ function runEffects(effects = pendingEffects) {
1116
1122
  }
1117
1123
  function runRenders() {
1118
1124
  for (; pendingRender; )
1119
- pendingRender.k.b?.y || pendingRender.H(pendingRender.k, pendingRender.I), pendingRender = pendingRender.d;
1125
+ pendingRender.g.b?.y || pendingRender.H(pendingRender.g, pendingRender.I), pendingRender = pendingRender.d;
1120
1126
  finishPendingScopes();
1121
1127
  }
1122
1128
  function comparePendingRenders(a, b) {
1123
- let aStart = ownerStartNode(a.k), bStart = ownerStartNode(b.k);
1129
+ if (a.g.e || b.g.e) return 0;
1130
+ let aStart = ownerStartNode(a.g), bStart = ownerStartNode(b.g);
1124
1131
  return aStart === bStart ? 0 : aStart ? bStart ? aStart.compareDocumentPosition(bStart) & 2 ? -1 : 1 : -1 : 1;
1125
1132
  }
1126
1133
  function ownerStartNode(scope) {
@@ -1129,11 +1136,11 @@ function ownerStartNode(scope) {
1129
1136
 
1130
1137
  // src/dom/abort-signal.ts
1131
1138
  function resetAbortSignal(scope, id) {
1132
- let ctrl = scope.h?.[id];
1133
- ctrl && (queueEffect(ctrl, abort), scope.h[id] = void 0);
1139
+ let ctrl = scope.j?.[id];
1140
+ ctrl && (queueEffect(ctrl, abort), scope.j[id] = void 0);
1134
1141
  }
1135
1142
  function getAbortSignal(scope, id) {
1136
- return scope.b && (scope.b.n ||= /* @__PURE__ */ new Set()).add(scope), ((scope.h ||= {})[id] ||= new AbortController()).signal;
1143
+ return scope.b && (scope.b.n ||= /* @__PURE__ */ new Set()).add(scope), ((scope.j ||= {})[id] ||= new AbortController()).signal;
1137
1144
  }
1138
1145
  function abort(ctrl) {
1139
1146
  ctrl.abort();
@@ -1188,7 +1195,7 @@ var classIdToScope = /* @__PURE__ */ new Map(), compat = {
1188
1195
  render(out, component, renderer, args) {
1189
1196
  let scope = component.scope;
1190
1197
  scope || (scope = classIdToScope.get(component.id), scope && (component.scope = scope, classIdToScope.delete(component.id)));
1191
- let applyArgs = renderer.e || noop, existing = !1;
1198
+ let applyArgs = renderer.f || noop, existing = !1;
1192
1199
  if (typeof args[0] == "object" && "renderBody" in args[0]) {
1193
1200
  let input = args[0], normalizedInput = args[0] = {};
1194
1201
  for (let key in input)
@@ -1218,18 +1225,18 @@ function mount(input = {}, reference, position) {
1218
1225
  runtimeId: DEFAULT_RUNTIME_ID,
1219
1226
  renderId: DEFAULT_RENDER_ID
1220
1227
  };
1221
- let args = this.e, effects = prepareEffects(() => {
1228
+ let args = this.f, effects = prepareEffects(() => {
1222
1229
  branch = createScope($global), dom = initRenderer(this, branch), args && args(branch, [input]);
1223
1230
  });
1224
1231
  switch (position) {
1232
+ case "beforebegin":
1233
+ reference.parentNode.insertBefore(dom, reference);
1234
+ break;
1225
1235
  case "afterbegin":
1226
1236
  reference.insertBefore(dom, reference.firstChild);
1227
1237
  break;
1228
1238
  case "afterend":
1229
- reference.parentElement.insertBefore(dom, reference.nextSibling);
1230
- break;
1231
- case "beforebegin":
1232
- reference.parentElement.insertBefore(dom, reference);
1239
+ reference.parentNode.insertBefore(dom, reference.nextSibling);
1233
1240
  break;
1234
1241
  default:
1235
1242
  reference.appendChild(dom);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.0.0-next.3.23",
3
+ "version": "6.0.0-next.3.25",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",