@marko/runtime-tags 0.3.43 → 0.3.44
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 +47 -59
- package/dist/debug/dom.mjs +47 -59
- package/dist/debug/html.js +48 -36
- package/dist/debug/html.mjs +48 -36
- package/dist/dom/compat.d.ts +2 -2
- package/dist/dom/control-flow.d.ts +1 -1
- package/dist/dom/renderer.d.ts +2 -3
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +48 -55
- package/dist/dom.mjs +48 -55
- package/dist/html/attrs.d.ts +6 -4
- package/dist/html.js +44 -33
- package/dist/html.mjs +44 -33
- package/dist/translator/index.js +75 -111
- package/package.json +1 -1
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") : {};
|
|
@@ -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,
|
|
1747
|
+
var dynamicTag = function dynamicTag2(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1748
|
+
const childScopeAccessor = nodeAccessor + "!" /* ConditionalScope */;
|
|
1788
1749
|
const rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
|
1789
|
-
|
|
1790
|
-
return (scope, newRendererOrOp) => {
|
|
1750
|
+
return (scope, newRendererOrOp, getInput) => {
|
|
1791
1751
|
if (newRendererOrOp === DIRTY) return;
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
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
|
|
1764
|
+
newRenderer || (getContent ? getContent(scope) : void 0),
|
|
1803
1765
|
createBranchScopeWithTagNameOrRenderer
|
|
1804
1766
|
);
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
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
|
-
|
|
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(
|
|
1974
|
-
const renderer = createRenderer("", 0,
|
|
1961
|
+
createRenderer(args, clone) {
|
|
1962
|
+
const renderer = createRenderer("", 0, 0, () => args);
|
|
1975
1963
|
renderer.___clone = clone;
|
|
1976
1964
|
return renderer;
|
|
1977
1965
|
},
|
package/dist/debug/dom.mjs
CHANGED
|
@@ -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") : {};
|
|
@@ -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,
|
|
1662
|
+
var dynamicTag = function dynamicTag2(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1663
|
+
const childScopeAccessor = nodeAccessor + "!" /* ConditionalScope */;
|
|
1702
1664
|
const rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
|
1703
|
-
|
|
1704
|
-
return (scope, newRendererOrOp) => {
|
|
1665
|
+
return (scope, newRendererOrOp, getInput) => {
|
|
1705
1666
|
if (newRendererOrOp === DIRTY) return;
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
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
|
|
1679
|
+
newRenderer || (getContent ? getContent(scope) : void 0),
|
|
1717
1680
|
createBranchScopeWithTagNameOrRenderer
|
|
1718
1681
|
);
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
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
|
-
|
|
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(
|
|
1888
|
-
const renderer = createRenderer("", 0,
|
|
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,
|
package/dist/debug/html.js
CHANGED
|
@@ -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
|
|
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 = " " +
|
|
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(
|
|
2272
|
-
return stringAttr("class", classValue(
|
|
2271
|
+
function classAttr(value) {
|
|
2272
|
+
return stringAttr("class", classValue(value));
|
|
2273
2273
|
}
|
|
2274
|
-
function styleAttr(
|
|
2275
|
-
return stringAttr("style", styleValue(
|
|
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) ?
|
|
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,
|
|
2359
|
-
return isVoid(
|
|
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
|
|
2420
|
+
const value = data[name];
|
|
2421
2421
|
switch (name) {
|
|
2422
2422
|
case "class":
|
|
2423
|
-
result += classAttr(
|
|
2423
|
+
result += classAttr(value);
|
|
2424
2424
|
break;
|
|
2425
2425
|
case "style":
|
|
2426
|
-
result += styleAttr(
|
|
2426
|
+
result += styleAttr(value);
|
|
2427
2427
|
break;
|
|
2428
2428
|
case "":
|
|
2429
2429
|
case "content":
|
|
2430
2430
|
break;
|
|
2431
2431
|
default:
|
|
2432
|
-
if (!isVoid(
|
|
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)] =
|
|
2440
|
+
events[getEventHandlerName(name)] = value;
|
|
2441
2441
|
} else if (!skip.test(name)) {
|
|
2442
|
-
result += nonVoidAttr(name,
|
|
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,
|
|
2465
|
-
return
|
|
2464
|
+
function stringAttr(name, value) {
|
|
2465
|
+
return value && " " + name + attrAssignment(value);
|
|
2466
2466
|
}
|
|
2467
|
-
function nonVoidAttr(name,
|
|
2468
|
-
switch (typeof
|
|
2467
|
+
function nonVoidAttr(name, value) {
|
|
2468
|
+
switch (typeof value) {
|
|
2469
2469
|
case "string":
|
|
2470
|
-
return
|
|
2470
|
+
return " " + name + attrAssignment(value);
|
|
2471
2471
|
case "boolean":
|
|
2472
|
-
return
|
|
2472
|
+
return " " + name;
|
|
2473
2473
|
case "number":
|
|
2474
|
-
return
|
|
2474
|
+
return " " + name + "=" + value;
|
|
2475
2475
|
case "object":
|
|
2476
|
-
if (
|
|
2477
|
-
return
|
|
2476
|
+
if (value instanceof RegExp) {
|
|
2477
|
+
return " " + name + attrAssignment(value.source);
|
|
2478
2478
|
}
|
|
2479
2479
|
break;
|
|
2480
2480
|
}
|
|
2481
|
-
return
|
|
2481
|
+
return " " + name + attrAssignment(value + "");
|
|
2482
2482
|
}
|
|
2483
|
-
|
|
2484
|
-
|
|
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
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
return
|
|
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 === "'" ? "'" : "&";
|
|
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 === '"' ? """ : "&";
|
|
2494
2506
|
}
|
|
2495
2507
|
|
|
2496
2508
|
// src/common/compat-meta.ts
|
package/dist/debug/html.mjs
CHANGED
|
@@ -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
|
|
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 = " " +
|
|
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(
|
|
2191
|
-
return stringAttr("class", classValue(
|
|
2190
|
+
function classAttr(value) {
|
|
2191
|
+
return stringAttr("class", classValue(value));
|
|
2192
2192
|
}
|
|
2193
|
-
function styleAttr(
|
|
2194
|
-
return stringAttr("style", styleValue(
|
|
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) ?
|
|
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,
|
|
2278
|
-
return isVoid(
|
|
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
|
|
2339
|
+
const value = data[name];
|
|
2340
2340
|
switch (name) {
|
|
2341
2341
|
case "class":
|
|
2342
|
-
result += classAttr(
|
|
2342
|
+
result += classAttr(value);
|
|
2343
2343
|
break;
|
|
2344
2344
|
case "style":
|
|
2345
|
-
result += styleAttr(
|
|
2345
|
+
result += styleAttr(value);
|
|
2346
2346
|
break;
|
|
2347
2347
|
case "":
|
|
2348
2348
|
case "content":
|
|
2349
2349
|
break;
|
|
2350
2350
|
default:
|
|
2351
|
-
if (!isVoid(
|
|
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)] =
|
|
2359
|
+
events[getEventHandlerName(name)] = value;
|
|
2360
2360
|
} else if (!skip.test(name)) {
|
|
2361
|
-
result += nonVoidAttr(name,
|
|
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,
|
|
2384
|
-
return
|
|
2383
|
+
function stringAttr(name, value) {
|
|
2384
|
+
return value && " " + name + attrAssignment(value);
|
|
2385
2385
|
}
|
|
2386
|
-
function nonVoidAttr(name,
|
|
2387
|
-
switch (typeof
|
|
2386
|
+
function nonVoidAttr(name, value) {
|
|
2387
|
+
switch (typeof value) {
|
|
2388
2388
|
case "string":
|
|
2389
|
-
return
|
|
2389
|
+
return " " + name + attrAssignment(value);
|
|
2390
2390
|
case "boolean":
|
|
2391
|
-
return
|
|
2391
|
+
return " " + name;
|
|
2392
2392
|
case "number":
|
|
2393
|
-
return
|
|
2393
|
+
return " " + name + "=" + value;
|
|
2394
2394
|
case "object":
|
|
2395
|
-
if (
|
|
2396
|
-
return
|
|
2395
|
+
if (value instanceof RegExp) {
|
|
2396
|
+
return " " + name + attrAssignment(value.source);
|
|
2397
2397
|
}
|
|
2398
2398
|
break;
|
|
2399
2399
|
}
|
|
2400
|
-
return
|
|
2400
|
+
return " " + name + attrAssignment(value + "");
|
|
2401
2401
|
}
|
|
2402
|
-
|
|
2403
|
-
|
|
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
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
return
|
|
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 === "'" ? "'" : "&";
|
|
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 === '"' ? """ : "&";
|
|
2413
2425
|
}
|
|
2414
2426
|
|
|
2415
2427
|
// src/common/compat-meta.ts
|
package/dist/dom/compat.d.ts
CHANGED
|
@@ -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
|
-
|
|
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(
|
|
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
|
};
|
|
@@ -3,7 +3,7 @@ import { type Renderer } from "./renderer";
|
|
|
3
3
|
import { type Signal, type SignalOp } from "./signals";
|
|
4
4
|
export declare function conditional(nodeAccessor: Accessor, ...branches: Renderer[]): Signal<number>;
|
|
5
5
|
export declare function patchDynamicTag(fn: <T extends typeof dynamicTag>(cond: T) => T): void;
|
|
6
|
-
export declare let dynamicTag: (nodeAccessor: Accessor,
|
|
6
|
+
export declare let dynamicTag: (nodeAccessor: Accessor, getContent?: ((scope: Scope) => Renderer) | 0, getTagVar?: (() => Signal<unknown>) | 0, inputIsArgs?: 1) => Signal<Renderer | string | undefined>;
|
|
7
7
|
export declare function setConditionalRenderer<T>(scope: Scope, nodeAccessor: Accessor, newRenderer: T, createBranch: (renderer: NonNullable<T>, $global: Scope["$global"], parentScope: Scope, parentNode: ParentNode) => BranchScope): void;
|
|
8
8
|
export declare function loopOf(nodeAccessor: Accessor, renderer: Renderer): (scope: Scope, valueOrOp: SignalOp | [all: unknown[], by?: ((item: unknown, index: number) => unknown) | undefined]) => void;
|
|
9
9
|
export declare function loopIn(nodeAccessor: Accessor, renderer: Renderer): (scope: Scope, valueOrOp: SignalOp | [obj: {}, by?: ((key: string, v: unknown) => unknown) | undefined]) => void;
|
package/dist/dom/renderer.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import {
|
|
1
|
+
import { type BranchScope, type Scope } from "../common/types";
|
|
2
|
+
import type { Signal } from "./signals";
|
|
3
3
|
export type Renderer = {
|
|
4
4
|
___id: symbol;
|
|
5
5
|
___template: string;
|
|
@@ -13,7 +13,6 @@ type SetupFn = (scope: Scope) => void;
|
|
|
13
13
|
export declare function createBranchScopeWithRenderer(renderer: Renderer, $global: Scope["$global"], parentScope: Scope, parentNode: ParentNode): BranchScope;
|
|
14
14
|
export declare function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer: Renderer | string, $global: Scope["$global"], parentScope: Scope, parentNode: ParentNode): BranchScope;
|
|
15
15
|
export declare function initBranch(renderer: Renderer, branch: BranchScope, parentNode: ParentNode): void;
|
|
16
|
-
export declare function dynamicTagAttrs(nodeAccessor: Accessor, getContent?: (scope: Scope) => Renderer, inputIsArgs?: boolean): (scope: Scope, attrsOrOp: (() => Record<string, unknown>) | SignalOp) => void;
|
|
17
16
|
export declare function createRendererWithOwner(template: string, rawWalks?: string | 0, setup?: SetupFn | 0, getArgs?: () => Signal<unknown>): (owner?: Scope) => Renderer;
|
|
18
17
|
export declare function createRenderer(template: string, walks?: string | 0, setup?: SetupFn | 0, getArgs?: () => Signal<unknown>): Renderer;
|
|
19
18
|
export {};
|