marko 6.0.89 → 6.0.91

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
@@ -223,10 +223,24 @@ function createDelegator() {
223
223
  }
224
224
  function handleDelegated(ev) {
225
225
  let target = !rendering && ev.target;
226
+ if (true) {
227
+ Object.defineProperty(ev, "currentTarget", {
228
+ configurable: true,
229
+ get() {
230
+ console.error(
231
+ "Event.currentTarget is not supported in Marko's delegated events. Instead use an element reference or the second parameter of the event handler."
232
+ );
233
+ return null;
234
+ }
235
+ });
236
+ }
226
237
  while (target) {
227
238
  target["$" + ev.type]?.(ev, target);
228
239
  target = ev.bubbles && !ev.cancelBubble && target.parentNode;
229
240
  }
241
+ if (true) {
242
+ delete ev.currentTarget;
243
+ }
230
244
  }
231
245
 
232
246
  // src/dom/resolve-cursor-position.ts
@@ -1673,6 +1687,7 @@ function longestIncreasingSubsequence(a) {
1673
1687
  function _await(nodeAccessor, renderer) {
1674
1688
  const promiseAccessor = "Promise:" /* Promise */ + nodeAccessor;
1675
1689
  const branchAccessor = "ConditionalScope:" /* ConditionalScope */ + nodeAccessor;
1690
+ enableBranches();
1676
1691
  return (scope, promise) => {
1677
1692
  const referenceNode = scope[nodeAccessor];
1678
1693
  const tryWithPlaceholder = findBranchWithKey(
@@ -1990,6 +2005,14 @@ function loop(nodeAccessor, renderer, forEach) {
1990
2005
  const newMap = scope["LoopScopeMap:" /* LoopScopeMap */ + nodeAccessor] = /* @__PURE__ */ new Map();
1991
2006
  const newArray = scope["LoopScopeArray:" /* LoopScopeArray */ + nodeAccessor] = [];
1992
2007
  forEach(value, (key, args) => {
2008
+ if (true) {
2009
+ if (newMap.has(key)) {
2010
+ console.error(
2011
+ `A <for> tag's \`by\` attribute must return a unique value for each item, but a duplicate was found matching:`,
2012
+ key
2013
+ );
2014
+ }
2015
+ }
1993
2016
  const branch = oldMap?.get(key) || createAndSetupBranch(scope.$global, renderer, scope, parentNode);
1994
2017
  params?.(branch, args);
1995
2018
  newMap.set(key, branch);
@@ -123,10 +123,24 @@ function createDelegator() {
123
123
  }
124
124
  function handleDelegated(ev) {
125
125
  let target = !rendering && ev.target;
126
+ if (true) {
127
+ Object.defineProperty(ev, "currentTarget", {
128
+ configurable: true,
129
+ get() {
130
+ console.error(
131
+ "Event.currentTarget is not supported in Marko's delegated events. Instead use an element reference or the second parameter of the event handler."
132
+ );
133
+ return null;
134
+ }
135
+ });
136
+ }
126
137
  while (target) {
127
138
  target["$" + ev.type]?.(ev, target);
128
139
  target = ev.bubbles && !ev.cancelBubble && target.parentNode;
129
140
  }
141
+ if (true) {
142
+ delete ev.currentTarget;
143
+ }
130
144
  }
131
145
 
132
146
  // src/dom/resolve-cursor-position.ts
@@ -1573,6 +1587,7 @@ function longestIncreasingSubsequence(a) {
1573
1587
  function _await(nodeAccessor, renderer) {
1574
1588
  const promiseAccessor = "Promise:" /* Promise */ + nodeAccessor;
1575
1589
  const branchAccessor = "ConditionalScope:" /* ConditionalScope */ + nodeAccessor;
1590
+ enableBranches();
1576
1591
  return (scope, promise) => {
1577
1592
  const referenceNode = scope[nodeAccessor];
1578
1593
  const tryWithPlaceholder = findBranchWithKey(
@@ -1890,6 +1905,14 @@ function loop(nodeAccessor, renderer, forEach) {
1890
1905
  const newMap = scope["LoopScopeMap:" /* LoopScopeMap */ + nodeAccessor] = /* @__PURE__ */ new Map();
1891
1906
  const newArray = scope["LoopScopeArray:" /* LoopScopeArray */ + nodeAccessor] = [];
1892
1907
  forEach(value, (key, args) => {
1908
+ if (true) {
1909
+ if (newMap.has(key)) {
1910
+ console.error(
1911
+ `A <for> tag's \`by\` attribute must return a unique value for each item, but a duplicate was found matching:`,
1912
+ key
1913
+ );
1914
+ }
1915
+ }
1893
1916
  const branch = oldMap?.get(key) || createAndSetupBranch(scope.$global, renderer, scope, parentNode);
1894
1917
  params?.(branch, args);
1895
1918
  newMap.set(key, branch);
@@ -749,20 +749,28 @@ function writeAssigned(state) {
749
749
  }
750
750
  if (state.mutations.length) {
751
751
  for (const mutation of state.mutations) {
752
+ const hasSeen = state.refs.get(mutation.object)?.id;
752
753
  const objectStartIndex = state.buf.push(
753
- state.buf.length === 0 ? "(" : ",("
754
+ state.buf.length === 0 ? "" : ","
754
755
  );
755
756
  if (writeProp(state, mutation.object, null, "")) {
756
757
  const objectRef = state.refs.get(mutation.object);
757
- if (objectRef && !objectRef.id) {
758
- objectRef.id = nextRefAccess(state);
759
- 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
+ }
760
767
  }
761
768
  } else {
762
769
  state.buf.push("void 0");
763
770
  }
771
+ const isCall = mutation.type === 0 /* call */;
764
772
  const valueStartIndex = state.buf.push(
765
- 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)) + "="
766
774
  );
767
775
  if (writeProp(state, mutation.value, null, "")) {
768
776
  const valueRef = state.refs.get(mutation.value);
@@ -773,7 +781,9 @@ function writeAssigned(state) {
773
781
  } else {
774
782
  state.buf.push("void 0");
775
783
  }
776
- state.buf.push(")");
784
+ if (isCall) {
785
+ state.buf.push(")");
786
+ }
777
787
  }
778
788
  state.mutations = [];
779
789
  if (state.assigned.size) {
@@ -1862,6 +1872,15 @@ function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMark
1862
1872
  const loopScopes = /* @__PURE__ */ new Map();
1863
1873
  forOf(list, (item, index) => {
1864
1874
  const branchId = _peek_scope_id();
1875
+ const itemKey = forOfBy(by, item, index);
1876
+ if (true) {
1877
+ if (by && loopScopes.has(itemKey)) {
1878
+ console.error(
1879
+ `A <for> tag's \`by\` attribute must return a unique value for each item, but a duplicate was found matching:`,
1880
+ itemKey
1881
+ );
1882
+ }
1883
+ }
1865
1884
  if (resumeMarker) {
1866
1885
  if (singleNode) {
1867
1886
  flushBranchIds = " " + branchId + flushBranchIds;
@@ -1874,7 +1893,7 @@ function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMark
1874
1893
  }
1875
1894
  withBranchId(branchId, () => {
1876
1895
  cb(item, index);
1877
- loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
1896
+ loopScopes.set(itemKey, writeScope(branchId, {}));
1878
1897
  });
1879
1898
  });
1880
1899
  if (loopScopes.size) {
@@ -1903,6 +1922,15 @@ function _for_in(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarke
1903
1922
  const loopScopes = /* @__PURE__ */ new Map();
1904
1923
  forIn(obj, (key, value) => {
1905
1924
  const branchId = _peek_scope_id();
1925
+ const itemKey = forInBy(by, key, value);
1926
+ if (true) {
1927
+ if (by && loopScopes.has(itemKey)) {
1928
+ console.error(
1929
+ `A <for> tag's \`by\` attribute must return a unique value for each item, but a duplicate was found matching:`,
1930
+ itemKey
1931
+ );
1932
+ }
1933
+ }
1906
1934
  if (resumeMarker) {
1907
1935
  if (singleNode) {
1908
1936
  flushBranchIds = " " + branchId + flushBranchIds;
@@ -1915,7 +1943,7 @@ function _for_in(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarke
1915
1943
  }
1916
1944
  withBranchId(branchId, () => {
1917
1945
  cb(key, value);
1918
- loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
1946
+ loopScopes.set(itemKey, writeScope(branchId, {}));
1919
1947
  });
1920
1948
  });
1921
1949
  if (loopScopes.size) {
@@ -1944,6 +1972,15 @@ function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, ser
1944
1972
  const loopScopes = /* @__PURE__ */ new Map();
1945
1973
  forTo(to, from, step, (i) => {
1946
1974
  const branchId = _peek_scope_id();
1975
+ const itemKey = forStepBy(by, i);
1976
+ if (true) {
1977
+ if (by && loopScopes.has(itemKey)) {
1978
+ console.error(
1979
+ `A <for> tag's \`by\` attribute must return a unique value for each item, but a duplicate was found matching:`,
1980
+ itemKey
1981
+ );
1982
+ }
1983
+ }
1947
1984
  if (resumeMarker) {
1948
1985
  if (singleNode) {
1949
1986
  flushBranchIds = " " + branchId + flushBranchIds;
@@ -1956,7 +1993,7 @@ function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, ser
1956
1993
  }
1957
1994
  withBranchId(branchId, () => {
1958
1995
  cb(i);
1959
- loopScopes.set(forStepBy(by, i), writeScope(branchId, {}));
1996
+ loopScopes.set(itemKey, writeScope(branchId, {}));
1960
1997
  });
1961
1998
  });
1962
1999
  if (loopScopes.size) {
@@ -1985,6 +2022,15 @@ function _for_until(to, from, step, cb, by, scopeId, accessor, serializeBranch,
1985
2022
  const loopScopes = /* @__PURE__ */ new Map();
1986
2023
  forUntil(to, from, step, (i) => {
1987
2024
  const branchId = _peek_scope_id();
2025
+ const itemKey = forStepBy(by, i);
2026
+ if (true) {
2027
+ if (by && loopScopes.has(itemKey)) {
2028
+ console.error(
2029
+ `A <for> tag's \`by\` attribute must return a unique value for each item, but a duplicate was found matching:`,
2030
+ itemKey
2031
+ );
2032
+ }
2033
+ }
1988
2034
  if (resumeMarker) {
1989
2035
  if (singleNode) {
1990
2036
  flushBranchIds = " " + branchId + flushBranchIds;
@@ -1997,7 +2043,7 @@ function _for_until(to, from, step, cb, by, scopeId, accessor, serializeBranch,
1997
2043
  }
1998
2044
  withBranchId(branchId, () => {
1999
2045
  cb(i);
2000
- loopScopes.set(forStepBy(by, i), writeScope(branchId, {}));
2046
+ loopScopes.set(itemKey, writeScope(branchId, {}));
2001
2047
  });
2002
2048
  });
2003
2049
  if (loopScopes.size) {
@@ -660,20 +660,28 @@ function writeAssigned(state) {
660
660
  }
661
661
  if (state.mutations.length) {
662
662
  for (const mutation of state.mutations) {
663
+ const hasSeen = state.refs.get(mutation.object)?.id;
663
664
  const objectStartIndex = state.buf.push(
664
- state.buf.length === 0 ? "(" : ",("
665
+ state.buf.length === 0 ? "" : ","
665
666
  );
666
667
  if (writeProp(state, mutation.object, null, "")) {
667
668
  const objectRef = state.refs.get(mutation.object);
668
- if (objectRef && !objectRef.id) {
669
- objectRef.id = nextRefAccess(state);
670
- 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
+ }
671
678
  }
672
679
  } else {
673
680
  state.buf.push("void 0");
674
681
  }
682
+ const isCall = mutation.type === 0 /* call */;
675
683
  const valueStartIndex = state.buf.push(
676
- 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)) + "="
677
685
  );
678
686
  if (writeProp(state, mutation.value, null, "")) {
679
687
  const valueRef = state.refs.get(mutation.value);
@@ -684,7 +692,9 @@ function writeAssigned(state) {
684
692
  } else {
685
693
  state.buf.push("void 0");
686
694
  }
687
- state.buf.push(")");
695
+ if (isCall) {
696
+ state.buf.push(")");
697
+ }
688
698
  }
689
699
  state.mutations = [];
690
700
  if (state.assigned.size) {
@@ -1773,6 +1783,15 @@ function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMark
1773
1783
  const loopScopes = /* @__PURE__ */ new Map();
1774
1784
  forOf(list, (item, index) => {
1775
1785
  const branchId = _peek_scope_id();
1786
+ const itemKey = forOfBy(by, item, index);
1787
+ if (true) {
1788
+ if (by && loopScopes.has(itemKey)) {
1789
+ console.error(
1790
+ `A <for> tag's \`by\` attribute must return a unique value for each item, but a duplicate was found matching:`,
1791
+ itemKey
1792
+ );
1793
+ }
1794
+ }
1776
1795
  if (resumeMarker) {
1777
1796
  if (singleNode) {
1778
1797
  flushBranchIds = " " + branchId + flushBranchIds;
@@ -1785,7 +1804,7 @@ function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMark
1785
1804
  }
1786
1805
  withBranchId(branchId, () => {
1787
1806
  cb(item, index);
1788
- loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
1807
+ loopScopes.set(itemKey, writeScope(branchId, {}));
1789
1808
  });
1790
1809
  });
1791
1810
  if (loopScopes.size) {
@@ -1814,6 +1833,15 @@ function _for_in(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarke
1814
1833
  const loopScopes = /* @__PURE__ */ new Map();
1815
1834
  forIn(obj, (key, value) => {
1816
1835
  const branchId = _peek_scope_id();
1836
+ const itemKey = forInBy(by, key, value);
1837
+ if (true) {
1838
+ if (by && loopScopes.has(itemKey)) {
1839
+ console.error(
1840
+ `A <for> tag's \`by\` attribute must return a unique value for each item, but a duplicate was found matching:`,
1841
+ itemKey
1842
+ );
1843
+ }
1844
+ }
1817
1845
  if (resumeMarker) {
1818
1846
  if (singleNode) {
1819
1847
  flushBranchIds = " " + branchId + flushBranchIds;
@@ -1826,7 +1854,7 @@ function _for_in(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarke
1826
1854
  }
1827
1855
  withBranchId(branchId, () => {
1828
1856
  cb(key, value);
1829
- loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
1857
+ loopScopes.set(itemKey, writeScope(branchId, {}));
1830
1858
  });
1831
1859
  });
1832
1860
  if (loopScopes.size) {
@@ -1855,6 +1883,15 @@ function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, ser
1855
1883
  const loopScopes = /* @__PURE__ */ new Map();
1856
1884
  forTo(to, from, step, (i) => {
1857
1885
  const branchId = _peek_scope_id();
1886
+ const itemKey = forStepBy(by, i);
1887
+ if (true) {
1888
+ if (by && loopScopes.has(itemKey)) {
1889
+ console.error(
1890
+ `A <for> tag's \`by\` attribute must return a unique value for each item, but a duplicate was found matching:`,
1891
+ itemKey
1892
+ );
1893
+ }
1894
+ }
1858
1895
  if (resumeMarker) {
1859
1896
  if (singleNode) {
1860
1897
  flushBranchIds = " " + branchId + flushBranchIds;
@@ -1867,7 +1904,7 @@ function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, ser
1867
1904
  }
1868
1905
  withBranchId(branchId, () => {
1869
1906
  cb(i);
1870
- loopScopes.set(forStepBy(by, i), writeScope(branchId, {}));
1907
+ loopScopes.set(itemKey, writeScope(branchId, {}));
1871
1908
  });
1872
1909
  });
1873
1910
  if (loopScopes.size) {
@@ -1896,6 +1933,15 @@ function _for_until(to, from, step, cb, by, scopeId, accessor, serializeBranch,
1896
1933
  const loopScopes = /* @__PURE__ */ new Map();
1897
1934
  forUntil(to, from, step, (i) => {
1898
1935
  const branchId = _peek_scope_id();
1936
+ const itemKey = forStepBy(by, i);
1937
+ if (true) {
1938
+ if (by && loopScopes.has(itemKey)) {
1939
+ console.error(
1940
+ `A <for> tag's \`by\` attribute must return a unique value for each item, but a duplicate was found matching:`,
1941
+ itemKey
1942
+ );
1943
+ }
1944
+ }
1899
1945
  if (resumeMarker) {
1900
1946
  if (singleNode) {
1901
1947
  flushBranchIds = " " + branchId + flushBranchIds;
@@ -1908,7 +1954,7 @@ function _for_until(to, from, step, cb, by, scopeId, accessor, serializeBranch,
1908
1954
  }
1909
1955
  withBranchId(branchId, () => {
1910
1956
  cb(i);
1911
- loopScopes.set(forStepBy(by, i), writeScope(branchId, {}));
1957
+ loopScopes.set(itemKey, writeScope(branchId, {}));
1912
1958
  });
1913
1959
  });
1914
1960
  if (loopScopes.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
@@ -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
  }
@@ -1217,11 +1217,11 @@ function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMark
1217
1217
  if (serializeBranch !== 0) {
1218
1218
  let loopScopes = /* @__PURE__ */ new Map();
1219
1219
  forOf(list, (item, index) => {
1220
- let branchId = _peek_scope_id();
1220
+ let branchId = _peek_scope_id(), itemKey = forOfBy(by, item, index);
1221
1221
  resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(
1222
1222
  state.mark("[" /* BranchStart */, flushBranchIds)
1223
1223
  ), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1224
- cb(item, index), loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
1224
+ cb(item, index), loopScopes.set(itemKey, writeScope(branchId, {}));
1225
1225
  });
1226
1226
  }), loopScopes.size && writeScope(scopeId, {
1227
1227
  ["m" /* LoopScopeMap */ + accessor]: loopScopes
@@ -1243,11 +1243,11 @@ function _for_in(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarke
1243
1243
  if (serializeBranch !== 0) {
1244
1244
  let loopScopes = /* @__PURE__ */ new Map();
1245
1245
  forIn(obj, (key, value) => {
1246
- let branchId = _peek_scope_id();
1246
+ let branchId = _peek_scope_id(), itemKey = forInBy(by, key, value);
1247
1247
  resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(
1248
1248
  state.mark("[" /* BranchStart */, flushBranchIds)
1249
1249
  ), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1250
- cb(key, value), loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
1250
+ cb(key, value), loopScopes.set(itemKey, writeScope(branchId, {}));
1251
1251
  });
1252
1252
  }), loopScopes.size && writeScope(scopeId, {
1253
1253
  ["m" /* LoopScopeMap */ + accessor]: loopScopes
@@ -1269,11 +1269,11 @@ function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, ser
1269
1269
  if (serializeBranch !== 0) {
1270
1270
  let loopScopes = /* @__PURE__ */ new Map();
1271
1271
  forTo(to, from, step, (i) => {
1272
- let branchId = _peek_scope_id();
1272
+ let branchId = _peek_scope_id(), itemKey = forStepBy(by, i);
1273
1273
  resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(
1274
1274
  state.mark("[" /* BranchStart */, flushBranchIds)
1275
1275
  ), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1276
- cb(i), loopScopes.set(forStepBy(by, i), writeScope(branchId, {}));
1276
+ cb(i), loopScopes.set(itemKey, writeScope(branchId, {}));
1277
1277
  });
1278
1278
  }), loopScopes.size && writeScope(scopeId, {
1279
1279
  ["m" /* LoopScopeMap */ + accessor]: loopScopes
@@ -1295,11 +1295,11 @@ function _for_until(to, from, step, cb, by, scopeId, accessor, serializeBranch,
1295
1295
  if (serializeBranch !== 0) {
1296
1296
  let loopScopes = /* @__PURE__ */ new Map();
1297
1297
  forUntil(to, from, step, (i) => {
1298
- let branchId = _peek_scope_id();
1298
+ let branchId = _peek_scope_id(), itemKey = forStepBy(by, i);
1299
1299
  resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(
1300
1300
  state.mark("[" /* BranchStart */, flushBranchIds)
1301
1301
  ), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1302
- cb(i), loopScopes.set(forStepBy(by, i), writeScope(branchId, {}));
1302
+ cb(i), loopScopes.set(itemKey, writeScope(branchId, {}));
1303
1303
  });
1304
1304
  }), loopScopes.size && writeScope(scopeId, {
1305
1305
  ["m" /* LoopScopeMap */ + accessor]: loopScopes
package/dist/html.mjs CHANGED
@@ -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
  }
@@ -1131,11 +1131,11 @@ function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMark
1131
1131
  if (serializeBranch !== 0) {
1132
1132
  let loopScopes = /* @__PURE__ */ new Map();
1133
1133
  forOf(list, (item, index) => {
1134
- let branchId = _peek_scope_id();
1134
+ let branchId = _peek_scope_id(), itemKey = forOfBy(by, item, index);
1135
1135
  resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(
1136
1136
  state.mark("[" /* BranchStart */, flushBranchIds)
1137
1137
  ), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1138
- cb(item, index), loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
1138
+ cb(item, index), loopScopes.set(itemKey, writeScope(branchId, {}));
1139
1139
  });
1140
1140
  }), loopScopes.size && writeScope(scopeId, {
1141
1141
  ["m" /* LoopScopeMap */ + accessor]: loopScopes
@@ -1157,11 +1157,11 @@ function _for_in(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarke
1157
1157
  if (serializeBranch !== 0) {
1158
1158
  let loopScopes = /* @__PURE__ */ new Map();
1159
1159
  forIn(obj, (key, value) => {
1160
- let branchId = _peek_scope_id();
1160
+ let branchId = _peek_scope_id(), itemKey = forInBy(by, key, value);
1161
1161
  resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(
1162
1162
  state.mark("[" /* BranchStart */, flushBranchIds)
1163
1163
  ), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1164
- cb(key, value), loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
1164
+ cb(key, value), loopScopes.set(itemKey, writeScope(branchId, {}));
1165
1165
  });
1166
1166
  }), loopScopes.size && writeScope(scopeId, {
1167
1167
  ["m" /* LoopScopeMap */ + accessor]: loopScopes
@@ -1183,11 +1183,11 @@ function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, ser
1183
1183
  if (serializeBranch !== 0) {
1184
1184
  let loopScopes = /* @__PURE__ */ new Map();
1185
1185
  forTo(to, from, step, (i) => {
1186
- let branchId = _peek_scope_id();
1186
+ let branchId = _peek_scope_id(), itemKey = forStepBy(by, i);
1187
1187
  resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(
1188
1188
  state.mark("[" /* BranchStart */, flushBranchIds)
1189
1189
  ), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1190
- cb(i), loopScopes.set(forStepBy(by, i), writeScope(branchId, {}));
1190
+ cb(i), loopScopes.set(itemKey, writeScope(branchId, {}));
1191
1191
  });
1192
1192
  }), loopScopes.size && writeScope(scopeId, {
1193
1193
  ["m" /* LoopScopeMap */ + accessor]: loopScopes
@@ -1209,11 +1209,11 @@ function _for_until(to, from, step, cb, by, scopeId, accessor, serializeBranch,
1209
1209
  if (serializeBranch !== 0) {
1210
1210
  let loopScopes = /* @__PURE__ */ new Map();
1211
1211
  forUntil(to, from, step, (i) => {
1212
- let branchId = _peek_scope_id();
1212
+ let branchId = _peek_scope_id(), itemKey = forStepBy(by, i);
1213
1213
  resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(
1214
1214
  state.mark("[" /* BranchStart */, flushBranchIds)
1215
1215
  ), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1216
- cb(i), loopScopes.set(forStepBy(by, i), writeScope(branchId, {}));
1216
+ cb(i), loopScopes.set(itemKey, writeScope(branchId, {}));
1217
1217
  });
1218
1218
  }), loopScopes.size && writeScope(scopeId, {
1219
1219
  ["m" /* LoopScopeMap */ + accessor]: loopScopes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.0.89",
3
+ "version": "6.0.91",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",