marko 6.0.88 → 6.0.90

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
@@ -1673,6 +1673,7 @@ function longestIncreasingSubsequence(a) {
1673
1673
  function _await(nodeAccessor, renderer) {
1674
1674
  const promiseAccessor = "Promise:" /* Promise */ + nodeAccessor;
1675
1675
  const branchAccessor = "ConditionalScope:" /* ConditionalScope */ + nodeAccessor;
1676
+ enableBranches();
1676
1677
  return (scope, promise) => {
1677
1678
  const referenceNode = scope[nodeAccessor];
1678
1679
  const tryWithPlaceholder = findBranchWithKey(
@@ -1573,6 +1573,7 @@ function longestIncreasingSubsequence(a) {
1573
1573
  function _await(nodeAccessor, renderer) {
1574
1574
  const promiseAccessor = "Promise:" /* Promise */ + nodeAccessor;
1575
1575
  const branchAccessor = "ConditionalScope:" /* ConditionalScope */ + nodeAccessor;
1576
+ enableBranches();
1576
1577
  return (scope, promise) => {
1577
1578
  const referenceNode = scope[nodeAccessor];
1578
1579
  const tryWithPlaceholder = findBranchWithKey(
@@ -308,7 +308,8 @@ var REORDER_RUNTIME_CODE = true ? (
308
308
  (placeholders[id] = placeholder).i++;
309
309
  } else if (op == "!") {
310
310
  if (runtime.l[id] && placeholders[id]) {
311
- placeholders[id].c();
311
+ nextSibling = node.nextSibling;
312
+ onNextSibling = () => placeholders[id].c();
312
313
  }
313
314
  } else if (node.tagName == "T" && (id = node.getAttribute(runtime.i))) {
314
315
  nextSibling = node.nextSibling;
@@ -342,7 +343,7 @@ var REORDER_RUNTIME_CODE = true ? (
342
343
  }
343
344
  };
344
345
  })`
345
- ) : `(e=>{if(e.j)return;let i,r,l,t={},c=(i,r)=>e.l[i].replaceWith(...r.childNodes);e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),e.j={},e.x=(a,d,n,o,u)=>{n==l&&i(),"#"==a?(t[d]=r).i++:"!"==a?e.l[d]&&t[d]&&t[d].c():"T"==n.tagName&&(d=n.getAttribute(e.i))&&(l=n.nextSibling,i=()=>{n.remove(),o||c(d,n),r.c()},r=t[d]||(o=t[d]={i:e.l[d]?1:2,c(i=e.l["^"+d]){if(--o.i)return 1;for(;(l=e.l[d].previousSibling||i).remove(),i!=l;);c(d,n)}}),(a=e.j[d])&&(u=r.c,r.c=()=>u()||a(e.r)))}})`;
346
+ ) : `(e=>{if(e.j)return;let i,l,r,t={},c=(i,l)=>e.l[i].replaceWith(...l.childNodes);e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),e.j={},e.x=(n,a,d,o,g)=>{d==r&&i(),"#"==n?(t[a]=l).i++:"!"==n?e.l[a]&&t[a]&&(r=d.nextSibling,i=()=>t[a].c()):"T"==d.tagName&&(a=d.getAttribute(e.i))&&(r=d.nextSibling,i=()=>{d.remove(),o||c(a,d),l.c()},l=t[a]||(o=t[a]={i:e.l[a]?1:2,c(i=e.l["^"+a]){if(--o.i)return 1;for(;(r=e.l[a].previousSibling||i).remove(),i!=r;);c(a,d)}}),(n=e.j[a])&&(g=l.c,l.c=()=>g()||n(e.r)))}})`;
346
347
 
347
348
  // src/html/serializer.ts
348
349
  var kTouchedIterator = Symbol();
@@ -748,20 +749,28 @@ function writeAssigned(state) {
748
749
  }
749
750
  if (state.mutations.length) {
750
751
  for (const mutation of state.mutations) {
752
+ const hasSeen = state.refs.get(mutation.object)?.id;
751
753
  const objectStartIndex = state.buf.push(
752
- state.buf.length === 0 ? "(" : ",("
754
+ state.buf.length === 0 ? "" : ","
753
755
  );
754
756
  if (writeProp(state, mutation.object, null, "")) {
755
757
  const objectRef = state.refs.get(mutation.object);
756
- if (objectRef && !objectRef.id) {
757
- objectRef.id = nextRefAccess(state);
758
- state.buf[objectStartIndex] = objectRef.id + "=" + state.buf[objectStartIndex];
758
+ if (objectRef) {
759
+ if (!objectRef.id) {
760
+ objectRef.id = nextRefAccess(state);
761
+ state.buf[objectStartIndex] = "(" + objectRef.id + "=" + state.buf[objectStartIndex];
762
+ state.buf.push(")");
763
+ } else if (!hasSeen) {
764
+ state.buf[objectStartIndex] = "(" + state.buf[objectStartIndex];
765
+ state.buf.push(")");
766
+ }
759
767
  }
760
768
  } else {
761
769
  state.buf.push("void 0");
762
770
  }
771
+ const isCall = mutation.type === 0 /* call */;
763
772
  const valueStartIndex = state.buf.push(
764
- mutation.type === 0 /* call */ ? ")" + (mutation.property === void 0 ? "" : toAccess(toObjectKey(mutation.property))) + "(" + (mutation.spread ? "..." : "") : toAccess(toObjectKey(mutation.property)) + "="
773
+ isCall ? (mutation.property === void 0 ? "" : toAccess(toObjectKey(mutation.property))) + "(" + (mutation.spread ? "..." : "") : toAccess(toObjectKey(mutation.property)) + "="
765
774
  );
766
775
  if (writeProp(state, mutation.value, null, "")) {
767
776
  const valueRef = state.refs.get(mutation.value);
@@ -772,7 +781,9 @@ function writeAssigned(state) {
772
781
  } else {
773
782
  state.buf.push("void 0");
774
783
  }
775
- state.buf.push(")");
784
+ if (isCall) {
785
+ state.buf.push(")");
786
+ }
776
787
  }
777
788
  state.mutations = [];
778
789
  if (state.assigned.size) {
@@ -219,7 +219,8 @@ var REORDER_RUNTIME_CODE = true ? (
219
219
  (placeholders[id] = placeholder).i++;
220
220
  } else if (op == "!") {
221
221
  if (runtime.l[id] && placeholders[id]) {
222
- placeholders[id].c();
222
+ nextSibling = node.nextSibling;
223
+ onNextSibling = () => placeholders[id].c();
223
224
  }
224
225
  } else if (node.tagName == "T" && (id = node.getAttribute(runtime.i))) {
225
226
  nextSibling = node.nextSibling;
@@ -253,7 +254,7 @@ var REORDER_RUNTIME_CODE = true ? (
253
254
  }
254
255
  };
255
256
  })`
256
- ) : `(e=>{if(e.j)return;let i,r,l,t={},c=(i,r)=>e.l[i].replaceWith(...r.childNodes);e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),e.j={},e.x=(a,d,n,o,u)=>{n==l&&i(),"#"==a?(t[d]=r).i++:"!"==a?e.l[d]&&t[d]&&t[d].c():"T"==n.tagName&&(d=n.getAttribute(e.i))&&(l=n.nextSibling,i=()=>{n.remove(),o||c(d,n),r.c()},r=t[d]||(o=t[d]={i:e.l[d]?1:2,c(i=e.l["^"+d]){if(--o.i)return 1;for(;(l=e.l[d].previousSibling||i).remove(),i!=l;);c(d,n)}}),(a=e.j[d])&&(u=r.c,r.c=()=>u()||a(e.r)))}})`;
257
+ ) : `(e=>{if(e.j)return;let i,l,r,t={},c=(i,l)=>e.l[i].replaceWith(...l.childNodes);e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),e.j={},e.x=(n,a,d,o,g)=>{d==r&&i(),"#"==n?(t[a]=l).i++:"!"==n?e.l[a]&&t[a]&&(r=d.nextSibling,i=()=>t[a].c()):"T"==d.tagName&&(a=d.getAttribute(e.i))&&(r=d.nextSibling,i=()=>{d.remove(),o||c(a,d),l.c()},l=t[a]||(o=t[a]={i:e.l[a]?1:2,c(i=e.l["^"+a]){if(--o.i)return 1;for(;(r=e.l[a].previousSibling||i).remove(),i!=r;);c(a,d)}}),(n=e.j[a])&&(g=l.c,l.c=()=>g()||n(e.r)))}})`;
257
258
 
258
259
  // src/html/serializer.ts
259
260
  var kTouchedIterator = Symbol();
@@ -659,20 +660,28 @@ function writeAssigned(state) {
659
660
  }
660
661
  if (state.mutations.length) {
661
662
  for (const mutation of state.mutations) {
663
+ const hasSeen = state.refs.get(mutation.object)?.id;
662
664
  const objectStartIndex = state.buf.push(
663
- state.buf.length === 0 ? "(" : ",("
665
+ state.buf.length === 0 ? "" : ","
664
666
  );
665
667
  if (writeProp(state, mutation.object, null, "")) {
666
668
  const objectRef = state.refs.get(mutation.object);
667
- if (objectRef && !objectRef.id) {
668
- objectRef.id = nextRefAccess(state);
669
- state.buf[objectStartIndex] = objectRef.id + "=" + state.buf[objectStartIndex];
669
+ if (objectRef) {
670
+ if (!objectRef.id) {
671
+ objectRef.id = nextRefAccess(state);
672
+ state.buf[objectStartIndex] = "(" + objectRef.id + "=" + state.buf[objectStartIndex];
673
+ state.buf.push(")");
674
+ } else if (!hasSeen) {
675
+ state.buf[objectStartIndex] = "(" + state.buf[objectStartIndex];
676
+ state.buf.push(")");
677
+ }
670
678
  }
671
679
  } else {
672
680
  state.buf.push("void 0");
673
681
  }
682
+ const isCall = mutation.type === 0 /* call */;
674
683
  const valueStartIndex = state.buf.push(
675
- mutation.type === 0 /* call */ ? ")" + (mutation.property === void 0 ? "" : toAccess(toObjectKey(mutation.property))) + "(" + (mutation.spread ? "..." : "") : toAccess(toObjectKey(mutation.property)) + "="
684
+ isCall ? (mutation.property === void 0 ? "" : toAccess(toObjectKey(mutation.property))) + "(" + (mutation.spread ? "..." : "") : toAccess(toObjectKey(mutation.property)) + "="
676
685
  );
677
686
  if (writeProp(state, mutation.value, null, "")) {
678
687
  const valueRef = state.refs.get(mutation.value);
@@ -683,7 +692,9 @@ function writeAssigned(state) {
683
692
  } else {
684
693
  state.buf.push("void 0");
685
694
  }
686
- state.buf.push(")");
695
+ if (isCall) {
696
+ state.buf.push(")");
697
+ }
687
698
  }
688
699
  state.mutations = [];
689
700
  if (state.assigned.size) {
package/dist/dom.js CHANGED
@@ -1091,7 +1091,7 @@ function longestIncreasingSubsequence(a) {
1091
1091
  // src/dom/control-flow.ts
1092
1092
  function _await(nodeAccessor, renderer) {
1093
1093
  let promiseAccessor = "n" /* Promise */ + nodeAccessor, branchAccessor = "d" /* ConditionalScope */ + nodeAccessor;
1094
- return (scope, promise) => {
1094
+ return enableBranches(), (scope, promise) => {
1095
1095
  let referenceNode = scope[nodeAccessor], tryWithPlaceholder = findBranchWithKey(
1096
1096
  scope,
1097
1097
  "d" /* PlaceholderContent */
package/dist/dom.mjs CHANGED
@@ -994,7 +994,7 @@ function longestIncreasingSubsequence(a) {
994
994
  // src/dom/control-flow.ts
995
995
  function _await(nodeAccessor, renderer) {
996
996
  let promiseAccessor = "n" /* Promise */ + nodeAccessor, branchAccessor = "d" /* ConditionalScope */ + nodeAccessor;
997
- return (scope, promise) => {
997
+ return enableBranches(), (scope, promise) => {
998
998
  let referenceNode = scope[nodeAccessor], tryWithPlaceholder = findBranchWithKey(
999
999
  scope,
1000
1000
  "d" /* PlaceholderContent */
package/dist/html.js CHANGED
@@ -195,7 +195,7 @@ function forStepBy(by, index) {
195
195
  }
196
196
 
197
197
  // src/html/inlined-runtimes.ts
198
- var WALKER_RUNTIME_CODE = '(e=>(self[e]||(self[e]=(l,f=e+l,s=f.length,a={},d=[],t=document,n=t.createTreeWalker(t,129))=>t=self[e][l]={i:f,d:t,l:a,v:d,x(){},w(e,l,r){for(;e=n.nextNode();)t.x(l=(l=e.data)&&!l.indexOf(f)&&(a[r=l.slice(s+1)]=e,l[s]),r,e),l>"#"&&d.push(e)}}),self[e]))', REORDER_RUNTIME_CODE = '(e=>{if(e.j)return;let i,r,l,t={},c=(i,r)=>e.l[i].replaceWith(...r.childNodes);e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),e.j={},e.x=(a,d,n,o,u)=>{n==l&&i(),"#"==a?(t[d]=r).i++:"!"==a?e.l[d]&&t[d]&&t[d].c():"T"==n.tagName&&(d=n.getAttribute(e.i))&&(l=n.nextSibling,i=()=>{n.remove(),o||c(d,n),r.c()},r=t[d]||(o=t[d]={i:e.l[d]?1:2,c(i=e.l["^"+d]){if(--o.i)return 1;for(;(l=e.l[d].previousSibling||i).remove(),i!=l;);c(d,n)}}),(a=e.j[d])&&(u=r.c,r.c=()=>u()||a(e.r)))}})';
198
+ var WALKER_RUNTIME_CODE = '(e=>(self[e]||(self[e]=(l,f=e+l,s=f.length,a={},d=[],t=document,n=t.createTreeWalker(t,129))=>t=self[e][l]={i:f,d:t,l:a,v:d,x(){},w(e,l,r){for(;e=n.nextNode();)t.x(l=(l=e.data)&&!l.indexOf(f)&&(a[r=l.slice(s+1)]=e,l[s]),r,e),l>"#"&&d.push(e)}}),self[e]))', REORDER_RUNTIME_CODE = '(e=>{if(e.j)return;let i,l,r,t={},c=(i,l)=>e.l[i].replaceWith(...l.childNodes);e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),e.j={},e.x=(n,a,d,o,g)=>{d==r&&i(),"#"==n?(t[a]=l).i++:"!"==n?e.l[a]&&t[a]&&(r=d.nextSibling,i=()=>t[a].c()):"T"==d.tagName&&(a=d.getAttribute(e.i))&&(r=d.nextSibling,i=()=>{d.remove(),o||c(a,d),l.c()},l=t[a]||(o=t[a]={i:e.l[a]?1:2,c(i=e.l["^"+a]){if(--o.i)return 1;for(;(r=e.l[a].previousSibling||i).remove(),i!=r;);c(a,d)}}),(n=e.j[a])&&(g=l.c,l.c=()=>g()||n(e.r)))}})';
199
199
 
200
200
  // src/html/serializer.ts
201
201
  var kTouchedIterator = Symbol(), { hasOwnProperty } = {}, Generator = (function* () {
@@ -539,23 +539,23 @@ function writeAssigned(state) {
539
539
  }
540
540
  if (state.mutations.length) {
541
541
  for (let mutation of state.mutations) {
542
- let objectStartIndex = state.buf.push(
543
- state.buf.length === 0 ? "(" : ",("
542
+ let hasSeen = state.refs.get(mutation.object)?.id, objectStartIndex = state.buf.push(
543
+ state.buf.length === 0 ? "" : ","
544
544
  );
545
545
  if (writeProp(state, mutation.object, null, "")) {
546
546
  let objectRef = state.refs.get(mutation.object);
547
- objectRef && !objectRef.id && (objectRef.id = nextRefAccess(state), state.buf[objectStartIndex] = objectRef.id + "=" + state.buf[objectStartIndex]);
547
+ objectRef && (objectRef.id ? hasSeen || (state.buf[objectStartIndex] = "(" + state.buf[objectStartIndex], state.buf.push(")")) : (objectRef.id = nextRefAccess(state), state.buf[objectStartIndex] = "(" + objectRef.id + "=" + state.buf[objectStartIndex], state.buf.push(")")));
548
548
  } else
549
549
  state.buf.push("void 0");
550
- let valueStartIndex = state.buf.push(
551
- mutation.type === 0 /* call */ ? ")" + (mutation.property === void 0 ? "" : toAccess(toObjectKey(mutation.property))) + "(" + (mutation.spread ? "..." : "") : toAccess(toObjectKey(mutation.property)) + "="
550
+ let isCall = mutation.type === 0 /* call */, valueStartIndex = state.buf.push(
551
+ isCall ? (mutation.property === void 0 ? "" : toAccess(toObjectKey(mutation.property))) + "(" + (mutation.spread ? "..." : "") : toAccess(toObjectKey(mutation.property)) + "="
552
552
  );
553
553
  if (writeProp(state, mutation.value, null, "")) {
554
554
  let valueRef = state.refs.get(mutation.value);
555
555
  valueRef && !valueRef.id && (valueRef.id = nextRefAccess(state), state.buf[valueStartIndex] = valueRef.id + "=" + state.buf[valueStartIndex]);
556
556
  } else
557
557
  state.buf.push("void 0");
558
- state.buf.push(")");
558
+ isCall && state.buf.push(")");
559
559
  }
560
560
  state.mutations = [], state.assigned.size && writeAssigned(state);
561
561
  }
package/dist/html.mjs CHANGED
@@ -109,7 +109,7 @@ function forStepBy(by, index) {
109
109
  }
110
110
 
111
111
  // src/html/inlined-runtimes.ts
112
- var WALKER_RUNTIME_CODE = '(e=>(self[e]||(self[e]=(l,f=e+l,s=f.length,a={},d=[],t=document,n=t.createTreeWalker(t,129))=>t=self[e][l]={i:f,d:t,l:a,v:d,x(){},w(e,l,r){for(;e=n.nextNode();)t.x(l=(l=e.data)&&!l.indexOf(f)&&(a[r=l.slice(s+1)]=e,l[s]),r,e),l>"#"&&d.push(e)}}),self[e]))', REORDER_RUNTIME_CODE = '(e=>{if(e.j)return;let i,r,l,t={},c=(i,r)=>e.l[i].replaceWith(...r.childNodes);e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),e.j={},e.x=(a,d,n,o,u)=>{n==l&&i(),"#"==a?(t[d]=r).i++:"!"==a?e.l[d]&&t[d]&&t[d].c():"T"==n.tagName&&(d=n.getAttribute(e.i))&&(l=n.nextSibling,i=()=>{n.remove(),o||c(d,n),r.c()},r=t[d]||(o=t[d]={i:e.l[d]?1:2,c(i=e.l["^"+d]){if(--o.i)return 1;for(;(l=e.l[d].previousSibling||i).remove(),i!=l;);c(d,n)}}),(a=e.j[d])&&(u=r.c,r.c=()=>u()||a(e.r)))}})';
112
+ var WALKER_RUNTIME_CODE = '(e=>(self[e]||(self[e]=(l,f=e+l,s=f.length,a={},d=[],t=document,n=t.createTreeWalker(t,129))=>t=self[e][l]={i:f,d:t,l:a,v:d,x(){},w(e,l,r){for(;e=n.nextNode();)t.x(l=(l=e.data)&&!l.indexOf(f)&&(a[r=l.slice(s+1)]=e,l[s]),r,e),l>"#"&&d.push(e)}}),self[e]))', REORDER_RUNTIME_CODE = '(e=>{if(e.j)return;let i,l,r,t={},c=(i,l)=>e.l[i].replaceWith(...l.childNodes);e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),e.j={},e.x=(n,a,d,o,g)=>{d==r&&i(),"#"==n?(t[a]=l).i++:"!"==n?e.l[a]&&t[a]&&(r=d.nextSibling,i=()=>t[a].c()):"T"==d.tagName&&(a=d.getAttribute(e.i))&&(r=d.nextSibling,i=()=>{d.remove(),o||c(a,d),l.c()},l=t[a]||(o=t[a]={i:e.l[a]?1:2,c(i=e.l["^"+a]){if(--o.i)return 1;for(;(r=e.l[a].previousSibling||i).remove(),i!=r;);c(a,d)}}),(n=e.j[a])&&(g=l.c,l.c=()=>g()||n(e.r)))}})';
113
113
 
114
114
  // src/html/serializer.ts
115
115
  var kTouchedIterator = Symbol(), { hasOwnProperty } = {}, Generator = (function* () {
@@ -453,23 +453,23 @@ function writeAssigned(state) {
453
453
  }
454
454
  if (state.mutations.length) {
455
455
  for (let mutation of state.mutations) {
456
- let objectStartIndex = state.buf.push(
457
- state.buf.length === 0 ? "(" : ",("
456
+ let hasSeen = state.refs.get(mutation.object)?.id, objectStartIndex = state.buf.push(
457
+ state.buf.length === 0 ? "" : ","
458
458
  );
459
459
  if (writeProp(state, mutation.object, null, "")) {
460
460
  let objectRef = state.refs.get(mutation.object);
461
- objectRef && !objectRef.id && (objectRef.id = nextRefAccess(state), state.buf[objectStartIndex] = objectRef.id + "=" + state.buf[objectStartIndex]);
461
+ objectRef && (objectRef.id ? hasSeen || (state.buf[objectStartIndex] = "(" + state.buf[objectStartIndex], state.buf.push(")")) : (objectRef.id = nextRefAccess(state), state.buf[objectStartIndex] = "(" + objectRef.id + "=" + state.buf[objectStartIndex], state.buf.push(")")));
462
462
  } else
463
463
  state.buf.push("void 0");
464
- let valueStartIndex = state.buf.push(
465
- mutation.type === 0 /* call */ ? ")" + (mutation.property === void 0 ? "" : toAccess(toObjectKey(mutation.property))) + "(" + (mutation.spread ? "..." : "") : toAccess(toObjectKey(mutation.property)) + "="
464
+ let isCall = mutation.type === 0 /* call */, valueStartIndex = state.buf.push(
465
+ isCall ? (mutation.property === void 0 ? "" : toAccess(toObjectKey(mutation.property))) + "(" + (mutation.spread ? "..." : "") : toAccess(toObjectKey(mutation.property)) + "="
466
466
  );
467
467
  if (writeProp(state, mutation.value, null, "")) {
468
468
  let valueRef = state.refs.get(mutation.value);
469
469
  valueRef && !valueRef.id && (valueRef.id = nextRefAccess(state), state.buf[valueStartIndex] = valueRef.id + "=" + state.buf[valueStartIndex]);
470
470
  } else
471
471
  state.buf.push("void 0");
472
- state.buf.push(")");
472
+ isCall && state.buf.push(")");
473
473
  }
474
474
  state.mutations = [], state.assigned.size && writeAssigned(state);
475
475
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.0.88",
3
+ "version": "6.0.90",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",