marko 6.1.20 → 6.1.21

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
@@ -718,8 +718,8 @@ function init(runtimeId = "M") {
718
718
  }
719
719
  };
720
720
  const serializeContext = ((data, registryId) => typeof data === "number" ? registryId ? registeredValues[registryId](getScope(data)) : getScope(data) : applyScopes(data));
721
- const createVisitBranches = (branchScopesStack = [], branchStarts = [], orphanBranches = [], curBranchScopes) => {
722
- return (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length) => {
721
+ const createVisitBranches = (branchScopesStack = [], branchStarts = [], orphanBranches = [], deferredOwners = [], curBranchScopes) => {
722
+ return (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length, j = deferredOwners.length) => {
723
723
  if (visitType !== "[") {
724
724
  visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit;
725
725
  accessor = "BranchScopes:" + lastToken;
@@ -746,6 +746,10 @@ function init(runtimeId = "M") {
746
746
  branch["#EndNode"] = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
747
747
  }
748
748
  while (i && orphanBranches[--i]["#Id"] > branchId) setParentBranch(orphanBranches.pop(), branch);
749
+ while (j && deferredOwners[--j]["#Id"] > branchId) {
750
+ const owner = deferredOwners.pop();
751
+ if (owner["#ClosestBranch"] !== owner) owner["#ClosestBranch"] = branch;
752
+ }
749
753
  nextToken();
750
754
  }
751
755
  if (endedBranches) {
@@ -758,7 +762,7 @@ function init(runtimeId = "M") {
758
762
  curBranchScopes = void 0;
759
763
  }
760
764
  branchStarts.push(visit);
761
- }
765
+ } else deferredOwners.push(visitScope);
762
766
  };
763
767
  };
764
768
  const nextToken = () => lastToken = visitText.slice(lastTokenIndex, (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1);
@@ -1350,7 +1354,12 @@ function _await_promise(nodeAccessor, params) {
1350
1354
  c() {
1351
1355
  if (--awaitCounter.i) return 1;
1352
1356
  if (tryBranch === scope[branchAccessor]) {
1353
- if (scope[nodeAccessor].parentNode) scope[nodeAccessor].replaceWith(scope[branchAccessor]["#StartNode"].parentNode);
1357
+ const anchor = scope[nodeAccessor];
1358
+ if (anchor.parentNode) {
1359
+ const detachedParent = scope[branchAccessor]["#StartNode"].parentNode;
1360
+ if (detachedParent === anchor.parentNode) anchor.remove();
1361
+ else anchor.replaceWith(detachedParent);
1362
+ }
1354
1363
  } else dismissPlaceholder(tryBranch);
1355
1364
  queueEffect(tryBranch, runPendingEffects);
1356
1365
  }
@@ -716,8 +716,8 @@ function init(runtimeId = "M") {
716
716
  }
717
717
  };
718
718
  const serializeContext = ((data, registryId) => typeof data === "number" ? registryId ? registeredValues[registryId](getScope(data)) : getScope(data) : applyScopes(data));
719
- const createVisitBranches = (branchScopesStack = [], branchStarts = [], orphanBranches = [], curBranchScopes) => {
720
- return (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length) => {
719
+ const createVisitBranches = (branchScopesStack = [], branchStarts = [], orphanBranches = [], deferredOwners = [], curBranchScopes) => {
720
+ return (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length, j = deferredOwners.length) => {
721
721
  if (visitType !== "[") {
722
722
  visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit;
723
723
  accessor = "BranchScopes:" + lastToken;
@@ -744,6 +744,10 @@ function init(runtimeId = "M") {
744
744
  branch["#EndNode"] = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
745
745
  }
746
746
  while (i && orphanBranches[--i]["#Id"] > branchId) setParentBranch(orphanBranches.pop(), branch);
747
+ while (j && deferredOwners[--j]["#Id"] > branchId) {
748
+ const owner = deferredOwners.pop();
749
+ if (owner["#ClosestBranch"] !== owner) owner["#ClosestBranch"] = branch;
750
+ }
747
751
  nextToken();
748
752
  }
749
753
  if (endedBranches) {
@@ -756,7 +760,7 @@ function init(runtimeId = "M") {
756
760
  curBranchScopes = void 0;
757
761
  }
758
762
  branchStarts.push(visit);
759
- }
763
+ } else deferredOwners.push(visitScope);
760
764
  };
761
765
  };
762
766
  const nextToken = () => lastToken = visitText.slice(lastTokenIndex, (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1);
@@ -1348,7 +1352,12 @@ function _await_promise(nodeAccessor, params) {
1348
1352
  c() {
1349
1353
  if (--awaitCounter.i) return 1;
1350
1354
  if (tryBranch === scope[branchAccessor]) {
1351
- if (scope[nodeAccessor].parentNode) scope[nodeAccessor].replaceWith(scope[branchAccessor]["#StartNode"].parentNode);
1355
+ const anchor = scope[nodeAccessor];
1356
+ if (anchor.parentNode) {
1357
+ const detachedParent = scope[branchAccessor]["#StartNode"].parentNode;
1358
+ if (detachedParent === anchor.parentNode) anchor.remove();
1359
+ else anchor.replaceWith(detachedParent);
1360
+ }
1352
1361
  } else dismissPlaceholder(tryBranch);
1353
1362
  queueEffect(tryBranch, runPendingEffects);
1354
1363
  }
package/dist/dom.js CHANGED
@@ -457,20 +457,24 @@ function init(runtimeId = "M") {
457
457
  let partial = partials[i];
458
458
  typeof partial == "number" ? scopeId += partial : (scopeId ? initScope(Object.assign(scopeLookup[scopeId] ||= (partial.L = scopeId, partial), partial)) : Object.assign(initGlobal(), partial), scopeId++);
459
459
  }
460
- }, serializeContext = ((data, registryId) => typeof data == "number" ? registryId ? registeredValues[registryId](getScope(data)) : getScope(data) : applyScopes(data)), createVisitBranches = (branchScopesStack = [], branchStarts = [], orphanBranches = [], curBranchScopes) => (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length) => {
460
+ }, serializeContext = ((data, registryId) => typeof data == "number" ? registryId ? registeredValues[registryId](getScope(data)) : getScope(data) : applyScopes(data)), createVisitBranches = (branchScopesStack = [], branchStarts = [], orphanBranches = [], deferredOwners = [], curBranchScopes) => (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length, j = deferredOwners.length) => {
461
461
  for (visitType !== "[" && (visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit, accessor = "A" + lastToken, singleNode = visitType !== "]" && visitType !== ")", nextToken()); branchId = +lastToken;) {
462
462
  if ((endedBranches ||= []).push(branch = getScope(branchId)), setParentBranch(branch, branch.F), (branch.O = render.p?.[branchId]) && (branch.O.m = render.m), singleNode) {
463
463
  for (; startVisit.previousSibling && ~visits.indexOf(startVisit = startVisit.previousSibling););
464
464
  branch.K = branch.S = startVisit, visitType === "'" && (branch.a = startVisit);
465
465
  } else curBranchScopes = push(curBranchScopes, branch), accessor && (visitScope[accessor] = curBranchScopes, curBranchScopes = branchScopesStack.pop()), startVisit = branchStarts.pop(), parent !== startVisit.parentNode && parent.prepend(startVisit), branch.S = startVisit, branch.K = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
466
466
  for (; i && orphanBranches[--i].L > branchId;) setParentBranch(orphanBranches.pop(), branch);
467
+ for (; j && deferredOwners[--j].L > branchId;) {
468
+ let owner = deferredOwners.pop();
469
+ owner.F !== owner && (owner.F = branch);
470
+ }
467
471
  nextToken();
468
472
  }
469
473
  if (endedBranches) {
470
474
  for (let ended of endedBranches) orphanBranches.push(ended);
471
475
  singleNode && (visitScope[accessor] = endedBranches.length > 1 ? endedBranches.reverse() : endedBranches[0]);
472
476
  }
473
- visitType === "[" && (endedBranches || (branchScopesStack.push(curBranchScopes), curBranchScopes = void 0), branchStarts.push(visit));
477
+ visitType === "[" ? (endedBranches || (branchScopesStack.push(curBranchScopes), curBranchScopes = void 0), branchStarts.push(visit)) : deferredOwners.push(visitScope);
474
478
  }, nextToken = () => lastToken = visitText.slice(lastTokenIndex, (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1), processResumes = (resumes = [], effects) => {
475
479
  let i = 0;
476
480
  for (; i < resumes.length; i++) {
@@ -883,7 +887,14 @@ function _await_promise(nodeAccessor, params) {
883
887
  i: 0,
884
888
  c() {
885
889
  if (--awaitCounter.i) return 1;
886
- tryBranch === scope[branchAccessor] ? scope[nodeAccessor].parentNode && scope[nodeAccessor].replaceWith(scope[branchAccessor].S.parentNode) : dismissPlaceholder(tryBranch), queueEffect(tryBranch, runPendingEffects);
890
+ if (tryBranch === scope[branchAccessor]) {
891
+ let anchor = scope[nodeAccessor];
892
+ if (anchor.parentNode) {
893
+ let detachedParent = scope[branchAccessor].S.parentNode;
894
+ detachedParent === anchor.parentNode ? anchor.remove() : anchor.replaceWith(detachedParent);
895
+ }
896
+ } else dismissPlaceholder(tryBranch);
897
+ queueEffect(tryBranch, runPendingEffects);
887
898
  }
888
899
  }), scope[promiseAccessor] || (awaitBranch && (awaitBranch.W ||= []), awaitCounter.i++ || requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(scope, () => {
889
900
  awaitBranch.V || (awaitBranch.S.parentNode.insertBefore(scope[nodeAccessor], awaitBranch.S), tempDetachBranch(tryBranch));
package/dist/dom.mjs CHANGED
@@ -456,20 +456,24 @@ function init(runtimeId = "M") {
456
456
  let partial = partials[i];
457
457
  typeof partial == "number" ? scopeId += partial : (scopeId ? initScope(Object.assign(scopeLookup[scopeId] ||= (partial.L = scopeId, partial), partial)) : Object.assign(initGlobal(), partial), scopeId++);
458
458
  }
459
- }, serializeContext = ((data, registryId) => typeof data == "number" ? registryId ? registeredValues[registryId](getScope(data)) : getScope(data) : applyScopes(data)), createVisitBranches = (branchScopesStack = [], branchStarts = [], orphanBranches = [], curBranchScopes) => (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length) => {
459
+ }, serializeContext = ((data, registryId) => typeof data == "number" ? registryId ? registeredValues[registryId](getScope(data)) : getScope(data) : applyScopes(data)), createVisitBranches = (branchScopesStack = [], branchStarts = [], orphanBranches = [], deferredOwners = [], curBranchScopes) => (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length, j = deferredOwners.length) => {
460
460
  for (visitType !== "[" && (visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit, accessor = "A" + lastToken, singleNode = visitType !== "]" && visitType !== ")", nextToken()); branchId = +lastToken;) {
461
461
  if ((endedBranches ||= []).push(branch = getScope(branchId)), setParentBranch(branch, branch.F), (branch.O = render.p?.[branchId]) && (branch.O.m = render.m), singleNode) {
462
462
  for (; startVisit.previousSibling && ~visits.indexOf(startVisit = startVisit.previousSibling););
463
463
  branch.K = branch.S = startVisit, visitType === "'" && (branch.a = startVisit);
464
464
  } else curBranchScopes = push(curBranchScopes, branch), accessor && (visitScope[accessor] = curBranchScopes, curBranchScopes = branchScopesStack.pop()), startVisit = branchStarts.pop(), parent !== startVisit.parentNode && parent.prepend(startVisit), branch.S = startVisit, branch.K = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
465
465
  for (; i && orphanBranches[--i].L > branchId;) setParentBranch(orphanBranches.pop(), branch);
466
+ for (; j && deferredOwners[--j].L > branchId;) {
467
+ let owner = deferredOwners.pop();
468
+ owner.F !== owner && (owner.F = branch);
469
+ }
466
470
  nextToken();
467
471
  }
468
472
  if (endedBranches) {
469
473
  for (let ended of endedBranches) orphanBranches.push(ended);
470
474
  singleNode && (visitScope[accessor] = endedBranches.length > 1 ? endedBranches.reverse() : endedBranches[0]);
471
475
  }
472
- visitType === "[" && (endedBranches || (branchScopesStack.push(curBranchScopes), curBranchScopes = void 0), branchStarts.push(visit));
476
+ visitType === "[" ? (endedBranches || (branchScopesStack.push(curBranchScopes), curBranchScopes = void 0), branchStarts.push(visit)) : deferredOwners.push(visitScope);
473
477
  }, nextToken = () => lastToken = visitText.slice(lastTokenIndex, (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1), processResumes = (resumes = [], effects) => {
474
478
  let i = 0;
475
479
  for (; i < resumes.length; i++) {
@@ -882,7 +886,14 @@ function _await_promise(nodeAccessor, params) {
882
886
  i: 0,
883
887
  c() {
884
888
  if (--awaitCounter.i) return 1;
885
- tryBranch === scope[branchAccessor] ? scope[nodeAccessor].parentNode && scope[nodeAccessor].replaceWith(scope[branchAccessor].S.parentNode) : dismissPlaceholder(tryBranch), queueEffect(tryBranch, runPendingEffects);
889
+ if (tryBranch === scope[branchAccessor]) {
890
+ let anchor = scope[nodeAccessor];
891
+ if (anchor.parentNode) {
892
+ let detachedParent = scope[branchAccessor].S.parentNode;
893
+ detachedParent === anchor.parentNode ? anchor.remove() : anchor.replaceWith(detachedParent);
894
+ }
895
+ } else dismissPlaceholder(tryBranch);
896
+ queueEffect(tryBranch, runPendingEffects);
886
897
  }
887
898
  }), scope[promiseAccessor] || (awaitBranch && (awaitBranch.W ||= []), awaitCounter.i++ || requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(scope, () => {
888
899
  awaitBranch.V || (awaitBranch.S.parentNode.insertBefore(scope[nodeAccessor], awaitBranch.S), tempDetachBranch(tryBranch));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.1.20",
3
+ "version": "6.1.21",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",