@marko/runtime-tags 0.3.43 → 0.3.45

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
@@ -47,7 +47,6 @@ __export(dom_exports, {
47
47
  data: () => data,
48
48
  dynamicClosure: () => dynamicClosure,
49
49
  dynamicTag: () => dynamicTag,
50
- dynamicTagAttrs: () => dynamicTagAttrs,
51
50
  effect: () => effect,
52
51
  forIn: () => forIn,
53
52
  forOf: () => forOf,
@@ -1693,45 +1692,6 @@ function initBranch(renderer, branch, parentNode) {
1693
1692
  queueRender(branch, renderer.___setup);
1694
1693
  }
1695
1694
  }
1696
- function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
1697
- return (scope, attrsOrOp) => {
1698
- const renderer = scope[nodeAccessor + "(" /* ConditionalRenderer */];
1699
- if (!renderer || attrsOrOp === DIRTY) {
1700
- return;
1701
- }
1702
- const childScope = scope[nodeAccessor + "!" /* ConditionalScope */];
1703
- if (attrsOrOp === MARK || attrsOrOp === CLEAN) {
1704
- return renderer.___args?.(childScope, attrsOrOp);
1705
- }
1706
- const content = getContent?.(scope);
1707
- if (typeof renderer === "string") {
1708
- const nodeAccessor2 = true ? `#${renderer}/0` : 0;
1709
- if (renderer === "textarea" && content) {
1710
- throw new Error(
1711
- "A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead."
1712
- );
1713
- }
1714
- setConditionalRenderer(
1715
- childScope,
1716
- nodeAccessor2,
1717
- content,
1718
- createBranchScopeWithTagNameOrRenderer
1719
- );
1720
- attrs(childScope, nodeAccessor2, attrsOrOp());
1721
- } else if (renderer.___args) {
1722
- const attributes = attrsOrOp();
1723
- renderer.___args(
1724
- childScope,
1725
- inputIsArgs ? attributes : [
1726
- content ? {
1727
- ...attributes,
1728
- content
1729
- } : attributes
1730
- ]
1731
- );
1732
- }
1733
- };
1734
- }
1735
1695
  function createRendererWithOwner(template, rawWalks, setup, getArgs) {
1736
1696
  let args;
1737
1697
  const id = true ? Symbol("Marko Renderer") : {};
@@ -1770,12 +1730,12 @@ function createCloneableHTML(html2, ns) {
1770
1730
  // src/dom/control-flow.ts
1771
1731
  function conditional(nodeAccessor, ...branches) {
1772
1732
  const branchAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
1773
- return (scope, newBranchIndexOrOp) => {
1774
- if (newBranchIndexOrOp !== scope[branchAccessor] && newBranchIndexOrOp !== DIRTY && newBranchIndexOrOp !== MARK && newBranchIndexOrOp !== CLEAN) {
1733
+ return (scope, newBranch) => {
1734
+ if (newBranch !== scope[branchAccessor]) {
1775
1735
  setConditionalRenderer(
1776
1736
  scope,
1777
1737
  nodeAccessor,
1778
- branches[scope[branchAccessor] = newBranchIndexOrOp],
1738
+ branches[scope[branchAccessor] = newBranch],
1779
1739
  createBranchScopeWithRenderer
1780
1740
  );
1781
1741
  }
@@ -1784,31 +1744,59 @@ function conditional(nodeAccessor, ...branches) {
1784
1744
  function patchDynamicTag(fn) {
1785
1745
  dynamicTag = fn(dynamicTag);
1786
1746
  }
1787
- var dynamicTag = function dynamicTag2(nodeAccessor, fn, getIntersection) {
1747
+ var dynamicTag = function dynamicTag2(nodeAccessor, getContent, getTagVar, inputIsArgs) {
1748
+ const childScopeAccessor = nodeAccessor + "!" /* ConditionalScope */;
1788
1749
  const rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
1789
- let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
1790
- return (scope, newRendererOrOp) => {
1750
+ return (scope, newRendererOrOp, getInput) => {
1791
1751
  if (newRendererOrOp === DIRTY) return;
1792
- const currentRenderer = scope[rendererAccessor];
1793
- let op = newRendererOrOp;
1794
- if (newRendererOrOp !== MARK && newRendererOrOp !== CLEAN) {
1795
- if (isDifferentRenderer(
1796
- currentRenderer,
1797
- scope[rendererAccessor] = normalizeDynamicRenderer(newRendererOrOp)
1798
- )) {
1752
+ if (newRendererOrOp === MARK || newRendererOrOp === CLEAN) {
1753
+ scope[rendererAccessor]?.___args?.(
1754
+ scope[childScopeAccessor],
1755
+ newRendererOrOp
1756
+ );
1757
+ } else {
1758
+ const newRenderer = normalizeDynamicRenderer(newRendererOrOp);
1759
+ if (!(rendererAccessor in scope) || isDifferentRenderer(scope[rendererAccessor], newRenderer)) {
1760
+ scope[rendererAccessor] = newRenderer;
1799
1761
  setConditionalRenderer(
1800
1762
  scope,
1801
1763
  nodeAccessor,
1802
- scope[rendererAccessor],
1764
+ newRenderer || (getContent ? getContent(scope) : void 0),
1803
1765
  createBranchScopeWithTagNameOrRenderer
1804
1766
  );
1805
- fn && fn(scope);
1806
- op = DIRTY;
1807
- } else {
1808
- op = CLEAN;
1767
+ if (getTagVar) {
1768
+ setTagVar(scope, childScopeAccessor, getTagVar());
1769
+ }
1770
+ if (getContent && typeof newRenderer === "string") {
1771
+ setConditionalRenderer(
1772
+ scope[childScopeAccessor],
1773
+ true ? `#${newRenderer}/0` : 0,
1774
+ getContent(scope),
1775
+ createBranchScopeWithRenderer
1776
+ );
1777
+ }
1778
+ }
1779
+ if (newRenderer) {
1780
+ const input = getInput?.();
1781
+ if (typeof newRenderer === "string") {
1782
+ attrs(
1783
+ scope[childScopeAccessor],
1784
+ true ? `#${newRenderer}/0` : 0,
1785
+ (inputIsArgs ? input[0] : input) || {}
1786
+ );
1787
+ } else {
1788
+ newRenderer.___args?.(
1789
+ scope[childScopeAccessor],
1790
+ inputIsArgs ? input : [
1791
+ getContent ? {
1792
+ ...input,
1793
+ content: getContent(scope)
1794
+ } : input || {}
1795
+ ]
1796
+ );
1797
+ }
1809
1798
  }
1810
1799
  }
1811
- intersection2?.(scope, op);
1812
1800
  };
1813
1801
  };
1814
1802
  function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2) {
@@ -1926,7 +1914,7 @@ function isDifferentRenderer(a, b) {
1926
1914
  // src/dom/compat.ts
1927
1915
  var classIdToBranch = /* @__PURE__ */ new Map();
1928
1916
  var compat = {
1929
- patchConditionals: patchDynamicTag,
1917
+ patchDynamicTag,
1930
1918
  queueEffect,
1931
1919
  init(warp10Noop) {
1932
1920
  register(SET_SCOPE_REGISTER_ID, (branch) => {
@@ -1970,8 +1958,8 @@ var compat = {
1970
1958
  }
1971
1959
  return value2;
1972
1960
  },
1973
- createRenderer(setup, clone, args) {
1974
- const renderer = createRenderer("", 0, setup, args && (() => args));
1961
+ createRenderer(args, clone) {
1962
+ const renderer = createRenderer("", 0, 0, () => args);
1975
1963
  renderer.___clone = clone;
1976
1964
  return renderer;
1977
1965
  },
@@ -1607,45 +1607,6 @@ function initBranch(renderer, branch, parentNode) {
1607
1607
  queueRender(branch, renderer.___setup);
1608
1608
  }
1609
1609
  }
1610
- function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
1611
- return (scope, attrsOrOp) => {
1612
- const renderer = scope[nodeAccessor + "(" /* ConditionalRenderer */];
1613
- if (!renderer || attrsOrOp === DIRTY) {
1614
- return;
1615
- }
1616
- const childScope = scope[nodeAccessor + "!" /* ConditionalScope */];
1617
- if (attrsOrOp === MARK || attrsOrOp === CLEAN) {
1618
- return renderer.___args?.(childScope, attrsOrOp);
1619
- }
1620
- const content = getContent?.(scope);
1621
- if (typeof renderer === "string") {
1622
- const nodeAccessor2 = true ? `#${renderer}/0` : 0;
1623
- if (renderer === "textarea" && content) {
1624
- throw new Error(
1625
- "A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead."
1626
- );
1627
- }
1628
- setConditionalRenderer(
1629
- childScope,
1630
- nodeAccessor2,
1631
- content,
1632
- createBranchScopeWithTagNameOrRenderer
1633
- );
1634
- attrs(childScope, nodeAccessor2, attrsOrOp());
1635
- } else if (renderer.___args) {
1636
- const attributes = attrsOrOp();
1637
- renderer.___args(
1638
- childScope,
1639
- inputIsArgs ? attributes : [
1640
- content ? {
1641
- ...attributes,
1642
- content
1643
- } : attributes
1644
- ]
1645
- );
1646
- }
1647
- };
1648
- }
1649
1610
  function createRendererWithOwner(template, rawWalks, setup, getArgs) {
1650
1611
  let args;
1651
1612
  const id = true ? Symbol("Marko Renderer") : {};
@@ -1684,12 +1645,12 @@ function createCloneableHTML(html2, ns) {
1684
1645
  // src/dom/control-flow.ts
1685
1646
  function conditional(nodeAccessor, ...branches) {
1686
1647
  const branchAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
1687
- return (scope, newBranchIndexOrOp) => {
1688
- if (newBranchIndexOrOp !== scope[branchAccessor] && newBranchIndexOrOp !== DIRTY && newBranchIndexOrOp !== MARK && newBranchIndexOrOp !== CLEAN) {
1648
+ return (scope, newBranch) => {
1649
+ if (newBranch !== scope[branchAccessor]) {
1689
1650
  setConditionalRenderer(
1690
1651
  scope,
1691
1652
  nodeAccessor,
1692
- branches[scope[branchAccessor] = newBranchIndexOrOp],
1653
+ branches[scope[branchAccessor] = newBranch],
1693
1654
  createBranchScopeWithRenderer
1694
1655
  );
1695
1656
  }
@@ -1698,31 +1659,59 @@ function conditional(nodeAccessor, ...branches) {
1698
1659
  function patchDynamicTag(fn) {
1699
1660
  dynamicTag = fn(dynamicTag);
1700
1661
  }
1701
- var dynamicTag = function dynamicTag2(nodeAccessor, fn, getIntersection) {
1662
+ var dynamicTag = function dynamicTag2(nodeAccessor, getContent, getTagVar, inputIsArgs) {
1663
+ const childScopeAccessor = nodeAccessor + "!" /* ConditionalScope */;
1702
1664
  const rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
1703
- let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
1704
- return (scope, newRendererOrOp) => {
1665
+ return (scope, newRendererOrOp, getInput) => {
1705
1666
  if (newRendererOrOp === DIRTY) return;
1706
- const currentRenderer = scope[rendererAccessor];
1707
- let op = newRendererOrOp;
1708
- if (newRendererOrOp !== MARK && newRendererOrOp !== CLEAN) {
1709
- if (isDifferentRenderer(
1710
- currentRenderer,
1711
- scope[rendererAccessor] = normalizeDynamicRenderer(newRendererOrOp)
1712
- )) {
1667
+ if (newRendererOrOp === MARK || newRendererOrOp === CLEAN) {
1668
+ scope[rendererAccessor]?.___args?.(
1669
+ scope[childScopeAccessor],
1670
+ newRendererOrOp
1671
+ );
1672
+ } else {
1673
+ const newRenderer = normalizeDynamicRenderer(newRendererOrOp);
1674
+ if (!(rendererAccessor in scope) || isDifferentRenderer(scope[rendererAccessor], newRenderer)) {
1675
+ scope[rendererAccessor] = newRenderer;
1713
1676
  setConditionalRenderer(
1714
1677
  scope,
1715
1678
  nodeAccessor,
1716
- scope[rendererAccessor],
1679
+ newRenderer || (getContent ? getContent(scope) : void 0),
1717
1680
  createBranchScopeWithTagNameOrRenderer
1718
1681
  );
1719
- fn && fn(scope);
1720
- op = DIRTY;
1721
- } else {
1722
- op = CLEAN;
1682
+ if (getTagVar) {
1683
+ setTagVar(scope, childScopeAccessor, getTagVar());
1684
+ }
1685
+ if (getContent && typeof newRenderer === "string") {
1686
+ setConditionalRenderer(
1687
+ scope[childScopeAccessor],
1688
+ true ? `#${newRenderer}/0` : 0,
1689
+ getContent(scope),
1690
+ createBranchScopeWithRenderer
1691
+ );
1692
+ }
1693
+ }
1694
+ if (newRenderer) {
1695
+ const input = getInput?.();
1696
+ if (typeof newRenderer === "string") {
1697
+ attrs(
1698
+ scope[childScopeAccessor],
1699
+ true ? `#${newRenderer}/0` : 0,
1700
+ (inputIsArgs ? input[0] : input) || {}
1701
+ );
1702
+ } else {
1703
+ newRenderer.___args?.(
1704
+ scope[childScopeAccessor],
1705
+ inputIsArgs ? input : [
1706
+ getContent ? {
1707
+ ...input,
1708
+ content: getContent(scope)
1709
+ } : input || {}
1710
+ ]
1711
+ );
1712
+ }
1723
1713
  }
1724
1714
  }
1725
- intersection2?.(scope, op);
1726
1715
  };
1727
1716
  };
1728
1717
  function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2) {
@@ -1840,7 +1829,7 @@ function isDifferentRenderer(a, b) {
1840
1829
  // src/dom/compat.ts
1841
1830
  var classIdToBranch = /* @__PURE__ */ new Map();
1842
1831
  var compat = {
1843
- patchConditionals: patchDynamicTag,
1832
+ patchDynamicTag,
1844
1833
  queueEffect,
1845
1834
  init(warp10Noop) {
1846
1835
  register(SET_SCOPE_REGISTER_ID, (branch) => {
@@ -1884,8 +1873,8 @@ var compat = {
1884
1873
  }
1885
1874
  return value2;
1886
1875
  },
1887
- createRenderer(setup, clone, args) {
1888
- const renderer = createRenderer("", 0, setup, args && (() => args));
1876
+ createRenderer(args, clone) {
1877
+ const renderer = createRenderer("", 0, 0, () => args);
1889
1878
  renderer.___clone = clone;
1890
1879
  return renderer;
1891
1880
  },
@@ -2028,7 +2017,6 @@ export {
2028
2017
  data,
2029
2018
  dynamicClosure,
2030
2019
  dynamicTag,
2031
- dynamicTagAttrs,
2032
2020
  effect,
2033
2021
  forIn,
2034
2022
  forOf,
@@ -744,7 +744,7 @@ function writeRegistered(state, val, parent, accessor, { access, scope }) {
744
744
  }
745
745
  state.buf.push(access + "(" + ensureId(state, scopeRef) + ")");
746
746
  } else {
747
- const pos = state.buf.push("");
747
+ const pos = state.buf.push("") - 1;
748
748
  const assigns = state.assigned.size;
749
749
  writeProp(state, scope, parent, "");
750
750
  const scopeRef2 = parent && state.refs.get(scope);
@@ -755,7 +755,7 @@ function writeRegistered(state, val, parent, accessor, { access, scope }) {
755
755
  fnRef.init = access + "(" + scopeId + ")";
756
756
  fnRef.assigns += ensureId(state, parent) + toAccess(accessor) + "=";
757
757
  } else {
758
- state.buf[pos - 2] += access + "(";
758
+ state.buf[pos] = access + "(" + state.buf[pos];
759
759
  state.buf.push(")");
760
760
  }
761
761
  }
@@ -1893,7 +1893,7 @@ var State2 = class {
1893
1893
  this.$global = $global2;
1894
1894
  this.$global = $global2;
1895
1895
  if ($global2.cspNonce) {
1896
- this.nonceAttr = " " + escapeAttrValue($global2.cspNonce + "");
1896
+ this.nonceAttr = " nonce" + attrAssignment($global2.cspNonce);
1897
1897
  }
1898
1898
  }
1899
1899
  tagId = 1;
@@ -2268,15 +2268,15 @@ function getFilteredGlobals($global2) {
2268
2268
  }
2269
2269
 
2270
2270
  // src/html/attrs.ts
2271
- function classAttr(val) {
2272
- return stringAttr("class", classValue(val));
2271
+ function classAttr(value) {
2272
+ return stringAttr("class", classValue(value));
2273
2273
  }
2274
- function styleAttr(val) {
2275
- return stringAttr("style", styleValue(val));
2274
+ function styleAttr(value) {
2275
+ return stringAttr("style", styleValue(value));
2276
2276
  }
2277
2277
  function optionValueAttr(value) {
2278
2278
  const { [kSelectedValue]: selectedValue } = getChunk()?.context || {};
2279
- return attr("value", value) + (!isVoid(value) && (Array.isArray(value) ? selectedValue.includes(value) : selectedValue === value) ? ` selected` : "");
2279
+ return attr("value", value) + (!isVoid(value) && (Array.isArray(value) ? selectedValue.includes(value) : selectedValue === value) ? " selected" : "");
2280
2280
  }
2281
2281
  var kSelectedValue = Symbol("selectedValue");
2282
2282
  function controllable_select_value(scopeId, nodeAccessor, value, valueChange, content) {
@@ -2355,8 +2355,8 @@ function controllable_detailsOrDialog_open(scopeId, nodeAccessor, open, openChan
2355
2355
  }
2356
2356
  return attr("open", open);
2357
2357
  }
2358
- function attr(name, val) {
2359
- return isVoid(val) ? "" : nonVoidAttr(name, val);
2358
+ function attr(name, value) {
2359
+ return isVoid(value) ? "" : nonVoidAttr(name, value);
2360
2360
  }
2361
2361
  function attrs(data, nodeAccessor, scopeId, tagName) {
2362
2362
  let result = "";
@@ -2417,19 +2417,19 @@ function attrs(data, nodeAccessor, scopeId, tagName) {
2417
2417
  break;
2418
2418
  }
2419
2419
  for (const name in data) {
2420
- const val = data[name];
2420
+ const value = data[name];
2421
2421
  switch (name) {
2422
2422
  case "class":
2423
- result += classAttr(val);
2423
+ result += classAttr(value);
2424
2424
  break;
2425
2425
  case "style":
2426
- result += styleAttr(val);
2426
+ result += styleAttr(value);
2427
2427
  break;
2428
2428
  case "":
2429
2429
  case "content":
2430
2430
  break;
2431
2431
  default:
2432
- if (!isVoid(val)) {
2432
+ if (!isVoid(value)) {
2433
2433
  if (isEventHandler(name)) {
2434
2434
  if (!events) {
2435
2435
  events = {};
@@ -2437,9 +2437,9 @@ function attrs(data, nodeAccessor, scopeId, tagName) {
2437
2437
  [nodeAccessor + "~" /* EventAttributes */]: events
2438
2438
  });
2439
2439
  }
2440
- events[getEventHandlerName(name)] = val;
2440
+ events[getEventHandlerName(name)] = value;
2441
2441
  } else if (!skip.test(name)) {
2442
- result += nonVoidAttr(name, val);
2442
+ result += nonVoidAttr(name, value);
2443
2443
  }
2444
2444
  }
2445
2445
  break;
@@ -2461,36 +2461,48 @@ function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange) {
2461
2461
  [nodeAccessor + ";" /* ControlledHandler */]: valueChange
2462
2462
  });
2463
2463
  }
2464
- function stringAttr(name, val) {
2465
- return val && ` ${name}=${escapeAttrValue(val)}`;
2464
+ function stringAttr(name, value) {
2465
+ return value && " " + name + attrAssignment(value);
2466
2466
  }
2467
- function nonVoidAttr(name, val) {
2468
- switch (typeof val) {
2467
+ function nonVoidAttr(name, value) {
2468
+ switch (typeof value) {
2469
2469
  case "string":
2470
- return ` ${name + attrAssignment(val)}`;
2470
+ return " " + name + attrAssignment(value);
2471
2471
  case "boolean":
2472
- return ` ${name}`;
2472
+ return " " + name;
2473
2473
  case "number":
2474
- return ` ${name}=${val}`;
2474
+ return " " + name + "=" + value;
2475
2475
  case "object":
2476
- if (val instanceof RegExp) {
2477
- return ` ${name + attrAssignment(val.source)}`;
2476
+ if (value instanceof RegExp) {
2477
+ return " " + name + attrAssignment(value.source);
2478
2478
  }
2479
2479
  break;
2480
2480
  }
2481
- return ` ${name + attrAssignment(val + "")}`;
2481
+ return " " + name + attrAssignment(value + "");
2482
2482
  }
2483
- function attrAssignment(val) {
2484
- return val ? `=${escapeAttrValue(val)}` : "";
2483
+ var singleQuoteAttrReplacements = /'|&(?=#?\w+;)/g;
2484
+ var doubleQuoteAttrReplacements = /"|&(?=#?\w+;)/g;
2485
+ var needsQuotedAttr = /["'>\s]|&#?\w+;|\/$/g;
2486
+ function attrAssignment(value) {
2487
+ return value ? needsQuotedAttr.test(value) ? value[needsQuotedAttr.lastIndex - 1] === (needsQuotedAttr.lastIndex = 0, '"') ? "='" + escapeSingleQuotedAttrValue(value) + "'" : '="' + escapeDoubleQuotedAttrValue(value) + '"' : "=" + value : "";
2485
2488
  }
2486
- var unsafeAttrChars = /["'>\s]/g;
2487
- function escapeAttrValue(str) {
2488
- if (unsafeAttrChars.test(str)) {
2489
- const c = str[unsafeAttrChars.lastIndex - 1];
2490
- unsafeAttrChars.lastIndex = 0;
2491
- return c === '"' ? `'${str.replace(/'/g, "&#39;")}'` : `"${str.replace(/"/g, "&#34;")}"`;
2492
- }
2493
- return str;
2489
+ function escapeSingleQuotedAttrValue(value) {
2490
+ return singleQuoteAttrReplacements.test(value) ? value.replace(
2491
+ singleQuoteAttrReplacements,
2492
+ replaceUnsafeSingleQuoteAttrChar
2493
+ ) : value;
2494
+ }
2495
+ function replaceUnsafeSingleQuoteAttrChar(match) {
2496
+ return match === "'" ? "&#39;" : "&amp;";
2497
+ }
2498
+ function escapeDoubleQuotedAttrValue(value) {
2499
+ return doubleQuoteAttrReplacements.test(value) ? value.replace(
2500
+ doubleQuoteAttrReplacements,
2501
+ replaceUnsafeDoubleQuoteAttrChar
2502
+ ) : value;
2503
+ }
2504
+ function replaceUnsafeDoubleQuoteAttrChar(match) {
2505
+ return match === '"' ? "&#34;" : "&amp;";
2494
2506
  }
2495
2507
 
2496
2508
  // src/common/compat-meta.ts
@@ -663,7 +663,7 @@ function writeRegistered(state, val, parent, accessor, { access, scope }) {
663
663
  }
664
664
  state.buf.push(access + "(" + ensureId(state, scopeRef) + ")");
665
665
  } else {
666
- const pos = state.buf.push("");
666
+ const pos = state.buf.push("") - 1;
667
667
  const assigns = state.assigned.size;
668
668
  writeProp(state, scope, parent, "");
669
669
  const scopeRef2 = parent && state.refs.get(scope);
@@ -674,7 +674,7 @@ function writeRegistered(state, val, parent, accessor, { access, scope }) {
674
674
  fnRef.init = access + "(" + scopeId + ")";
675
675
  fnRef.assigns += ensureId(state, parent) + toAccess(accessor) + "=";
676
676
  } else {
677
- state.buf[pos - 2] += access + "(";
677
+ state.buf[pos] = access + "(" + state.buf[pos];
678
678
  state.buf.push(")");
679
679
  }
680
680
  }
@@ -1812,7 +1812,7 @@ var State2 = class {
1812
1812
  this.$global = $global2;
1813
1813
  this.$global = $global2;
1814
1814
  if ($global2.cspNonce) {
1815
- this.nonceAttr = " " + escapeAttrValue($global2.cspNonce + "");
1815
+ this.nonceAttr = " nonce" + attrAssignment($global2.cspNonce);
1816
1816
  }
1817
1817
  }
1818
1818
  tagId = 1;
@@ -2187,15 +2187,15 @@ function getFilteredGlobals($global2) {
2187
2187
  }
2188
2188
 
2189
2189
  // src/html/attrs.ts
2190
- function classAttr(val) {
2191
- return stringAttr("class", classValue(val));
2190
+ function classAttr(value) {
2191
+ return stringAttr("class", classValue(value));
2192
2192
  }
2193
- function styleAttr(val) {
2194
- return stringAttr("style", styleValue(val));
2193
+ function styleAttr(value) {
2194
+ return stringAttr("style", styleValue(value));
2195
2195
  }
2196
2196
  function optionValueAttr(value) {
2197
2197
  const { [kSelectedValue]: selectedValue } = getChunk()?.context || {};
2198
- return attr("value", value) + (!isVoid(value) && (Array.isArray(value) ? selectedValue.includes(value) : selectedValue === value) ? ` selected` : "");
2198
+ return attr("value", value) + (!isVoid(value) && (Array.isArray(value) ? selectedValue.includes(value) : selectedValue === value) ? " selected" : "");
2199
2199
  }
2200
2200
  var kSelectedValue = Symbol("selectedValue");
2201
2201
  function controllable_select_value(scopeId, nodeAccessor, value, valueChange, content) {
@@ -2274,8 +2274,8 @@ function controllable_detailsOrDialog_open(scopeId, nodeAccessor, open, openChan
2274
2274
  }
2275
2275
  return attr("open", open);
2276
2276
  }
2277
- function attr(name, val) {
2278
- return isVoid(val) ? "" : nonVoidAttr(name, val);
2277
+ function attr(name, value) {
2278
+ return isVoid(value) ? "" : nonVoidAttr(name, value);
2279
2279
  }
2280
2280
  function attrs(data, nodeAccessor, scopeId, tagName) {
2281
2281
  let result = "";
@@ -2336,19 +2336,19 @@ function attrs(data, nodeAccessor, scopeId, tagName) {
2336
2336
  break;
2337
2337
  }
2338
2338
  for (const name in data) {
2339
- const val = data[name];
2339
+ const value = data[name];
2340
2340
  switch (name) {
2341
2341
  case "class":
2342
- result += classAttr(val);
2342
+ result += classAttr(value);
2343
2343
  break;
2344
2344
  case "style":
2345
- result += styleAttr(val);
2345
+ result += styleAttr(value);
2346
2346
  break;
2347
2347
  case "":
2348
2348
  case "content":
2349
2349
  break;
2350
2350
  default:
2351
- if (!isVoid(val)) {
2351
+ if (!isVoid(value)) {
2352
2352
  if (isEventHandler(name)) {
2353
2353
  if (!events) {
2354
2354
  events = {};
@@ -2356,9 +2356,9 @@ function attrs(data, nodeAccessor, scopeId, tagName) {
2356
2356
  [nodeAccessor + "~" /* EventAttributes */]: events
2357
2357
  });
2358
2358
  }
2359
- events[getEventHandlerName(name)] = val;
2359
+ events[getEventHandlerName(name)] = value;
2360
2360
  } else if (!skip.test(name)) {
2361
- result += nonVoidAttr(name, val);
2361
+ result += nonVoidAttr(name, value);
2362
2362
  }
2363
2363
  }
2364
2364
  break;
@@ -2380,36 +2380,48 @@ function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange) {
2380
2380
  [nodeAccessor + ";" /* ControlledHandler */]: valueChange
2381
2381
  });
2382
2382
  }
2383
- function stringAttr(name, val) {
2384
- return val && ` ${name}=${escapeAttrValue(val)}`;
2383
+ function stringAttr(name, value) {
2384
+ return value && " " + name + attrAssignment(value);
2385
2385
  }
2386
- function nonVoidAttr(name, val) {
2387
- switch (typeof val) {
2386
+ function nonVoidAttr(name, value) {
2387
+ switch (typeof value) {
2388
2388
  case "string":
2389
- return ` ${name + attrAssignment(val)}`;
2389
+ return " " + name + attrAssignment(value);
2390
2390
  case "boolean":
2391
- return ` ${name}`;
2391
+ return " " + name;
2392
2392
  case "number":
2393
- return ` ${name}=${val}`;
2393
+ return " " + name + "=" + value;
2394
2394
  case "object":
2395
- if (val instanceof RegExp) {
2396
- return ` ${name + attrAssignment(val.source)}`;
2395
+ if (value instanceof RegExp) {
2396
+ return " " + name + attrAssignment(value.source);
2397
2397
  }
2398
2398
  break;
2399
2399
  }
2400
- return ` ${name + attrAssignment(val + "")}`;
2400
+ return " " + name + attrAssignment(value + "");
2401
2401
  }
2402
- function attrAssignment(val) {
2403
- return val ? `=${escapeAttrValue(val)}` : "";
2402
+ var singleQuoteAttrReplacements = /'|&(?=#?\w+;)/g;
2403
+ var doubleQuoteAttrReplacements = /"|&(?=#?\w+;)/g;
2404
+ var needsQuotedAttr = /["'>\s]|&#?\w+;|\/$/g;
2405
+ function attrAssignment(value) {
2406
+ return value ? needsQuotedAttr.test(value) ? value[needsQuotedAttr.lastIndex - 1] === (needsQuotedAttr.lastIndex = 0, '"') ? "='" + escapeSingleQuotedAttrValue(value) + "'" : '="' + escapeDoubleQuotedAttrValue(value) + '"' : "=" + value : "";
2404
2407
  }
2405
- var unsafeAttrChars = /["'>\s]/g;
2406
- function escapeAttrValue(str) {
2407
- if (unsafeAttrChars.test(str)) {
2408
- const c = str[unsafeAttrChars.lastIndex - 1];
2409
- unsafeAttrChars.lastIndex = 0;
2410
- return c === '"' ? `'${str.replace(/'/g, "&#39;")}'` : `"${str.replace(/"/g, "&#34;")}"`;
2411
- }
2412
- return str;
2408
+ function escapeSingleQuotedAttrValue(value) {
2409
+ return singleQuoteAttrReplacements.test(value) ? value.replace(
2410
+ singleQuoteAttrReplacements,
2411
+ replaceUnsafeSingleQuoteAttrChar
2412
+ ) : value;
2413
+ }
2414
+ function replaceUnsafeSingleQuoteAttrChar(match) {
2415
+ return match === "'" ? "&#39;" : "&amp;";
2416
+ }
2417
+ function escapeDoubleQuotedAttrValue(value) {
2418
+ return doubleQuoteAttrReplacements.test(value) ? value.replace(
2419
+ doubleQuoteAttrReplacements,
2420
+ replaceUnsafeDoubleQuoteAttrChar
2421
+ ) : value;
2422
+ }
2423
+ function replaceUnsafeDoubleQuoteAttrChar(match) {
2424
+ return match === '"' ? "&#34;" : "&amp;";
2413
2425
  }
2414
2426
 
2415
2427
  // src/common/compat-meta.ts
@@ -2,7 +2,7 @@ import { patchDynamicTag } from "./control-flow";
2
2
  import { queueEffect } from "./queue";
3
3
  import { type Renderer } from "./renderer";
4
4
  export declare const compat: {
5
- patchConditionals: typeof patchDynamicTag;
5
+ patchDynamicTag: typeof patchDynamicTag;
6
6
  queueEffect: typeof queueEffect;
7
7
  init(warp10Noop: any): void;
8
8
  registerRenderer(fn: any): void;
@@ -16,6 +16,6 @@ export declare const compat: {
16
16
  runtimeId: string;
17
17
  componentIdPrefix: string;
18
18
  }): any;
19
- createRenderer(setup: Renderer["___setup"], clone: Renderer["___clone"], args: Renderer["___args"]): Renderer;
19
+ createRenderer(args: NonNullable<Renderer["___args"]>, clone: Renderer["___clone"]): Renderer;
20
20
  render(out: any, component: any, renderer: Renderer, args: any): Node | undefined;
21
21
  };