marko 6.0.0-3.9 → 6.0.0-next.3.16
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 +28 -22
- package/dist/debug/dom.mjs +28 -22
- package/dist/debug/html.js +36 -31
- package/dist/debug/html.mjs +36 -31
- package/dist/dom/compat.d.ts +1 -1
- package/dist/dom/renderer.d.ts +1 -1
- package/dist/dom/signals.d.ts +1 -1
- package/dist/dom.js +24 -19
- package/dist/dom.mjs +24 -19
- package/dist/html/attrs.d.ts +1 -1
- package/dist/html/dynamic-tag.d.ts +4 -4
- package/dist/html/writer.d.ts +5 -5
- package/dist/html.js +28 -23
- package/dist/html.mjs +28 -23
- package/dist/translator/index.d.ts +2 -0
- package/dist/translator/index.js +98 -63
- package/dist/translator/util/entry-builder.d.ts +1 -0
- package/dist/translator/util/runtime.d.ts +1 -0
- package/dist/translator/util/translate-attrs.d.ts +5 -3
- package/index.d.ts +144 -0
- package/package.json +24 -10
- package/tags-html.d.ts +3935 -0
package/dist/debug/dom.js
CHANGED
@@ -615,8 +615,8 @@ function setTagVarChange(scope, changeHandler) {
|
|
615
615
|
scope["@" /* TagVariableChange */] = changeHandler;
|
616
616
|
}
|
617
617
|
var tagVarSignalChange = (scope, value2) => scope["@" /* TagVariableChange */]?.(value2);
|
618
|
-
var
|
619
|
-
const signals =
|
618
|
+
var contentClosures = (content, childScope, op) => {
|
619
|
+
const signals = content?.___closureSignals;
|
620
620
|
if (signals) {
|
621
621
|
for (const signal of signals) {
|
622
622
|
signal(childScope, op);
|
@@ -787,7 +787,7 @@ function getEventHandlerName(name) {
|
|
787
787
|
return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
|
788
788
|
}
|
789
789
|
function normalizeDynamicRenderer(value2) {
|
790
|
-
if (value2) return value2.
|
790
|
+
if (value2) return value2.content || value2.default || value2;
|
791
791
|
}
|
792
792
|
|
793
793
|
// src/dom/reconcile.ts
|
@@ -1181,15 +1181,14 @@ function controllable_detailsOrDialog_open(scope, nodeAccessor, open, openChange
|
|
1181
1181
|
}
|
1182
1182
|
function controllable_detailsOrDialog_open_effect(scope, nodeAccessor) {
|
1183
1183
|
const el = scope[nodeAccessor];
|
1184
|
+
const hasChanged = () => el.open !== scope[nodeAccessor + ":" /* ControlledValue */];
|
1184
1185
|
syncControllable(
|
1185
1186
|
el,
|
1186
1187
|
el.tagName === "DIALOG" ? "close" : "toggle",
|
1187
|
-
|
1188
|
-
return scope[nodeAccessor + ";" /* ControlledHandler */] && el.open !== scope[nodeAccessor + ":" /* ControlledValue */];
|
1189
|
-
},
|
1188
|
+
hasChanged,
|
1190
1189
|
() => {
|
1191
1190
|
const openChange = scope[nodeAccessor + ";" /* ControlledHandler */];
|
1192
|
-
if (openChange) {
|
1191
|
+
if (openChange && hasChanged()) {
|
1193
1192
|
scope[nodeAccessor + "=" /* ControlledType */] = 6 /* Pending */;
|
1194
1193
|
openChange(el.open);
|
1195
1194
|
run();
|
@@ -1293,7 +1292,7 @@ function toValueProp(it) {
|
|
1293
1292
|
}
|
1294
1293
|
|
1295
1294
|
// src/dom/parse-html.ts
|
1296
|
-
var fallback = document.createTextNode("");
|
1295
|
+
var fallback = /* @__PURE__ */ document.createTextNode("");
|
1297
1296
|
var parser = /* @__PURE__ */ new Range();
|
1298
1297
|
function parseHTML(html2) {
|
1299
1298
|
return parser.createContextualFragment(html2);
|
@@ -1440,7 +1439,7 @@ function attrsInternal(scope, nodeAccessor, nextAttrs) {
|
|
1440
1439
|
case "style":
|
1441
1440
|
styleAttr(el, value2);
|
1442
1441
|
break;
|
1443
|
-
case "
|
1442
|
+
case "content":
|
1444
1443
|
break;
|
1445
1444
|
default: {
|
1446
1445
|
if (isEventHandler(name)) {
|
@@ -1645,7 +1644,7 @@ function initRenderer(renderer, scope) {
|
|
1645
1644
|
}
|
1646
1645
|
return dom;
|
1647
1646
|
}
|
1648
|
-
function dynamicTagAttrs(nodeAccessor,
|
1647
|
+
function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
1649
1648
|
return (scope, attrsOrOp) => {
|
1650
1649
|
const renderer = scope[nodeAccessor + "(" /* ConditionalRenderer */];
|
1651
1650
|
if (!renderer || attrsOrOp === DIRTY) {
|
@@ -1655,24 +1654,24 @@ function dynamicTagAttrs(nodeAccessor, getRenderBody, inputIsArgs) {
|
|
1655
1654
|
if (attrsOrOp === MARK || attrsOrOp === CLEAN) {
|
1656
1655
|
return renderer.___args?.(childScope, attrsOrOp);
|
1657
1656
|
}
|
1658
|
-
const
|
1657
|
+
const content = getContent?.(scope);
|
1659
1658
|
if (typeof renderer === "string") {
|
1660
1659
|
const nodeAccessor2 = true ? `#${renderer}/0` : 0;
|
1661
|
-
if (renderer === "textarea" &&
|
1660
|
+
if (renderer === "textarea" && content) {
|
1662
1661
|
throw new Error(
|
1663
|
-
"A dynamic tag rendering a `<textarea>` cannot have
|
1662
|
+
"A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead."
|
1664
1663
|
);
|
1665
1664
|
}
|
1666
|
-
setConditionalRendererOnlyChild(childScope, nodeAccessor2,
|
1665
|
+
setConditionalRendererOnlyChild(childScope, nodeAccessor2, content);
|
1667
1666
|
attrs(childScope, nodeAccessor2, attrsOrOp());
|
1668
1667
|
} else if (renderer.___args) {
|
1669
1668
|
const attributes = attrsOrOp();
|
1670
1669
|
renderer.___args(
|
1671
1670
|
childScope,
|
1672
1671
|
inputIsArgs ? attributes : [
|
1673
|
-
|
1672
|
+
content ? {
|
1674
1673
|
...attributes,
|
1675
|
-
|
1674
|
+
content
|
1676
1675
|
} : attributes
|
1677
1676
|
]
|
1678
1677
|
);
|
@@ -1742,7 +1741,7 @@ var conditional = function conditional2(nodeAccessor, fn, getIntersection) {
|
|
1742
1741
|
}
|
1743
1742
|
}
|
1744
1743
|
intersection2?.(scope, op);
|
1745
|
-
|
1744
|
+
contentClosures(currentRenderer, scope[childScopeAccessor], op);
|
1746
1745
|
};
|
1747
1746
|
};
|
1748
1747
|
function inConditionalScope(signal, nodeAccessor) {
|
@@ -1803,7 +1802,7 @@ var conditionalOnlyChild = function conditional3(nodeAccessor, fn, getIntersecti
|
|
1803
1802
|
}
|
1804
1803
|
}
|
1805
1804
|
intersection2?.(scope, op);
|
1806
|
-
|
1805
|
+
contentClosures(currentRenderer, scope[childScopeAccessor], op);
|
1807
1806
|
};
|
1808
1807
|
};
|
1809
1808
|
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer) {
|
@@ -2007,7 +2006,7 @@ var compat = {
|
|
2007
2006
|
renderer.___clone = clone;
|
2008
2007
|
return renderer;
|
2009
2008
|
},
|
2010
|
-
render(out, component, renderer,
|
2009
|
+
render(out, component, renderer, args) {
|
2011
2010
|
let scope = component.scope;
|
2012
2011
|
if (!scope) {
|
2013
2012
|
scope = classIdToScope.get(component.id);
|
@@ -2016,8 +2015,15 @@ var compat = {
|
|
2016
2015
|
classIdToScope.delete(component.id);
|
2017
2016
|
}
|
2018
2017
|
}
|
2019
|
-
const
|
2018
|
+
const applyArgs = renderer.___args || noop;
|
2020
2019
|
let existing = false;
|
2020
|
+
if (typeof args[0] === "object" && "renderBody" in args[0]) {
|
2021
|
+
const input = args[0];
|
2022
|
+
const normalizedInput = args[0] = {};
|
2023
|
+
for (const key in input) {
|
2024
|
+
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
2025
|
+
}
|
2026
|
+
}
|
2021
2027
|
component.effects = prepareEffects(() => {
|
2022
2028
|
if (!scope) {
|
2023
2029
|
scope = component.scope = createScopeWithRenderer(renderer, out.global);
|
@@ -2028,10 +2034,10 @@ var compat = {
|
|
2028
2034
|
}
|
2029
2035
|
}
|
2030
2036
|
} else {
|
2031
|
-
|
2037
|
+
applyArgs(scope, MARK);
|
2032
2038
|
existing = true;
|
2033
2039
|
}
|
2034
|
-
|
2040
|
+
applyArgs(scope, args);
|
2035
2041
|
});
|
2036
2042
|
if (!existing) {
|
2037
2043
|
return scope.___startNode === scope.___endNode ? scope.___startNode : scope.___startNode.parentNode;
|
package/dist/debug/dom.mjs
CHANGED
@@ -525,8 +525,8 @@ function setTagVarChange(scope, changeHandler) {
|
|
525
525
|
scope["@" /* TagVariableChange */] = changeHandler;
|
526
526
|
}
|
527
527
|
var tagVarSignalChange = (scope, value2) => scope["@" /* TagVariableChange */]?.(value2);
|
528
|
-
var
|
529
|
-
const signals =
|
528
|
+
var contentClosures = (content, childScope, op) => {
|
529
|
+
const signals = content?.___closureSignals;
|
530
530
|
if (signals) {
|
531
531
|
for (const signal of signals) {
|
532
532
|
signal(childScope, op);
|
@@ -697,7 +697,7 @@ function getEventHandlerName(name) {
|
|
697
697
|
return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
|
698
698
|
}
|
699
699
|
function normalizeDynamicRenderer(value2) {
|
700
|
-
if (value2) return value2.
|
700
|
+
if (value2) return value2.content || value2.default || value2;
|
701
701
|
}
|
702
702
|
|
703
703
|
// src/dom/reconcile.ts
|
@@ -1091,15 +1091,14 @@ function controllable_detailsOrDialog_open(scope, nodeAccessor, open, openChange
|
|
1091
1091
|
}
|
1092
1092
|
function controllable_detailsOrDialog_open_effect(scope, nodeAccessor) {
|
1093
1093
|
const el = scope[nodeAccessor];
|
1094
|
+
const hasChanged = () => el.open !== scope[nodeAccessor + ":" /* ControlledValue */];
|
1094
1095
|
syncControllable(
|
1095
1096
|
el,
|
1096
1097
|
el.tagName === "DIALOG" ? "close" : "toggle",
|
1097
|
-
|
1098
|
-
return scope[nodeAccessor + ";" /* ControlledHandler */] && el.open !== scope[nodeAccessor + ":" /* ControlledValue */];
|
1099
|
-
},
|
1098
|
+
hasChanged,
|
1100
1099
|
() => {
|
1101
1100
|
const openChange = scope[nodeAccessor + ";" /* ControlledHandler */];
|
1102
|
-
if (openChange) {
|
1101
|
+
if (openChange && hasChanged()) {
|
1103
1102
|
scope[nodeAccessor + "=" /* ControlledType */] = 6 /* Pending */;
|
1104
1103
|
openChange(el.open);
|
1105
1104
|
run();
|
@@ -1203,7 +1202,7 @@ function toValueProp(it) {
|
|
1203
1202
|
}
|
1204
1203
|
|
1205
1204
|
// src/dom/parse-html.ts
|
1206
|
-
var fallback = document.createTextNode("");
|
1205
|
+
var fallback = /* @__PURE__ */ document.createTextNode("");
|
1207
1206
|
var parser = /* @__PURE__ */ new Range();
|
1208
1207
|
function parseHTML(html2) {
|
1209
1208
|
return parser.createContextualFragment(html2);
|
@@ -1350,7 +1349,7 @@ function attrsInternal(scope, nodeAccessor, nextAttrs) {
|
|
1350
1349
|
case "style":
|
1351
1350
|
styleAttr(el, value2);
|
1352
1351
|
break;
|
1353
|
-
case "
|
1352
|
+
case "content":
|
1354
1353
|
break;
|
1355
1354
|
default: {
|
1356
1355
|
if (isEventHandler(name)) {
|
@@ -1555,7 +1554,7 @@ function initRenderer(renderer, scope) {
|
|
1555
1554
|
}
|
1556
1555
|
return dom;
|
1557
1556
|
}
|
1558
|
-
function dynamicTagAttrs(nodeAccessor,
|
1557
|
+
function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
1559
1558
|
return (scope, attrsOrOp) => {
|
1560
1559
|
const renderer = scope[nodeAccessor + "(" /* ConditionalRenderer */];
|
1561
1560
|
if (!renderer || attrsOrOp === DIRTY) {
|
@@ -1565,24 +1564,24 @@ function dynamicTagAttrs(nodeAccessor, getRenderBody, inputIsArgs) {
|
|
1565
1564
|
if (attrsOrOp === MARK || attrsOrOp === CLEAN) {
|
1566
1565
|
return renderer.___args?.(childScope, attrsOrOp);
|
1567
1566
|
}
|
1568
|
-
const
|
1567
|
+
const content = getContent?.(scope);
|
1569
1568
|
if (typeof renderer === "string") {
|
1570
1569
|
const nodeAccessor2 = true ? `#${renderer}/0` : 0;
|
1571
|
-
if (renderer === "textarea" &&
|
1570
|
+
if (renderer === "textarea" && content) {
|
1572
1571
|
throw new Error(
|
1573
|
-
"A dynamic tag rendering a `<textarea>` cannot have
|
1572
|
+
"A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead."
|
1574
1573
|
);
|
1575
1574
|
}
|
1576
|
-
setConditionalRendererOnlyChild(childScope, nodeAccessor2,
|
1575
|
+
setConditionalRendererOnlyChild(childScope, nodeAccessor2, content);
|
1577
1576
|
attrs(childScope, nodeAccessor2, attrsOrOp());
|
1578
1577
|
} else if (renderer.___args) {
|
1579
1578
|
const attributes = attrsOrOp();
|
1580
1579
|
renderer.___args(
|
1581
1580
|
childScope,
|
1582
1581
|
inputIsArgs ? attributes : [
|
1583
|
-
|
1582
|
+
content ? {
|
1584
1583
|
...attributes,
|
1585
|
-
|
1584
|
+
content
|
1586
1585
|
} : attributes
|
1587
1586
|
]
|
1588
1587
|
);
|
@@ -1652,7 +1651,7 @@ var conditional = function conditional2(nodeAccessor, fn, getIntersection) {
|
|
1652
1651
|
}
|
1653
1652
|
}
|
1654
1653
|
intersection2?.(scope, op);
|
1655
|
-
|
1654
|
+
contentClosures(currentRenderer, scope[childScopeAccessor], op);
|
1656
1655
|
};
|
1657
1656
|
};
|
1658
1657
|
function inConditionalScope(signal, nodeAccessor) {
|
@@ -1713,7 +1712,7 @@ var conditionalOnlyChild = function conditional3(nodeAccessor, fn, getIntersecti
|
|
1713
1712
|
}
|
1714
1713
|
}
|
1715
1714
|
intersection2?.(scope, op);
|
1716
|
-
|
1715
|
+
contentClosures(currentRenderer, scope[childScopeAccessor], op);
|
1717
1716
|
};
|
1718
1717
|
};
|
1719
1718
|
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer) {
|
@@ -1917,7 +1916,7 @@ var compat = {
|
|
1917
1916
|
renderer.___clone = clone;
|
1918
1917
|
return renderer;
|
1919
1918
|
},
|
1920
|
-
render(out, component, renderer,
|
1919
|
+
render(out, component, renderer, args) {
|
1921
1920
|
let scope = component.scope;
|
1922
1921
|
if (!scope) {
|
1923
1922
|
scope = classIdToScope.get(component.id);
|
@@ -1926,8 +1925,15 @@ var compat = {
|
|
1926
1925
|
classIdToScope.delete(component.id);
|
1927
1926
|
}
|
1928
1927
|
}
|
1929
|
-
const
|
1928
|
+
const applyArgs = renderer.___args || noop;
|
1930
1929
|
let existing = false;
|
1930
|
+
if (typeof args[0] === "object" && "renderBody" in args[0]) {
|
1931
|
+
const input = args[0];
|
1932
|
+
const normalizedInput = args[0] = {};
|
1933
|
+
for (const key in input) {
|
1934
|
+
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1935
|
+
}
|
1936
|
+
}
|
1931
1937
|
component.effects = prepareEffects(() => {
|
1932
1938
|
if (!scope) {
|
1933
1939
|
scope = component.scope = createScopeWithRenderer(renderer, out.global);
|
@@ -1938,10 +1944,10 @@ var compat = {
|
|
1938
1944
|
}
|
1939
1945
|
}
|
1940
1946
|
} else {
|
1941
|
-
|
1947
|
+
applyArgs(scope, MARK);
|
1942
1948
|
existing = true;
|
1943
1949
|
}
|
1944
|
-
|
1950
|
+
applyArgs(scope, args);
|
1945
1951
|
});
|
1946
1952
|
if (!existing) {
|
1947
1953
|
return scope.___startNode === scope.___endNode ? scope.___startNode : scope.___startNode.parentNode;
|
package/dist/debug/html.js
CHANGED
@@ -153,7 +153,7 @@ function isVoid(value) {
|
|
153
153
|
return value == null || value === false;
|
154
154
|
}
|
155
155
|
function normalizeDynamicRenderer(value) {
|
156
|
-
if (value) return value.
|
156
|
+
if (value) return value.content || value.default || value;
|
157
157
|
}
|
158
158
|
|
159
159
|
// src/html/content.ts
|
@@ -1548,9 +1548,9 @@ function ensureScopeWithId(scopeId) {
|
|
1548
1548
|
function $global() {
|
1549
1549
|
return $chunk.boundary.state.$global;
|
1550
1550
|
}
|
1551
|
-
function fork(promise,
|
1551
|
+
function fork(promise, content) {
|
1552
1552
|
if (!isPromise(promise)) {
|
1553
|
-
|
1553
|
+
content(promise);
|
1554
1554
|
return;
|
1555
1555
|
}
|
1556
1556
|
const chunk = $chunk;
|
@@ -1566,7 +1566,7 @@ function fork(promise, renderBody) {
|
|
1566
1566
|
if (chunk.async) {
|
1567
1567
|
chunk.async = false;
|
1568
1568
|
if (!boundary.signal.aborted) {
|
1569
|
-
chunk.render(
|
1569
|
+
chunk.render(content, value);
|
1570
1570
|
boundary.endAsync(chunk);
|
1571
1571
|
}
|
1572
1572
|
}
|
@@ -1577,27 +1577,27 @@ function fork(promise, renderBody) {
|
|
1577
1577
|
}
|
1578
1578
|
);
|
1579
1579
|
}
|
1580
|
-
function tryPlaceholder(
|
1580
|
+
function tryPlaceholder(content, placeholder) {
|
1581
1581
|
const chunk = $chunk;
|
1582
1582
|
const { boundary } = chunk;
|
1583
1583
|
const body = new Chunk(boundary, null, chunk.context);
|
1584
|
-
if (body === body.render(
|
1584
|
+
if (body === body.render(content)) {
|
1585
1585
|
chunk.append(body);
|
1586
1586
|
return;
|
1587
1587
|
}
|
1588
1588
|
chunk.next = $chunk = new Chunk(boundary, chunk.next, body.context);
|
1589
1589
|
chunk.placeholderBody = body;
|
1590
|
-
chunk.placeholderRender =
|
1590
|
+
chunk.placeholderRender = placeholder;
|
1591
1591
|
}
|
1592
|
-
function tryCatch(
|
1592
|
+
function tryCatch(content, catchContent) {
|
1593
1593
|
const chunk = $chunk;
|
1594
1594
|
const { boundary } = chunk;
|
1595
1595
|
const { state } = boundary;
|
1596
1596
|
const catchBoundary = new Boundary(state);
|
1597
1597
|
const body = new Chunk(catchBoundary, null, chunk.context);
|
1598
|
-
const bodyEnd = body.render(
|
1598
|
+
const bodyEnd = body.render(content);
|
1599
1599
|
if (catchBoundary.signal.aborted) {
|
1600
|
-
|
1600
|
+
catchContent(catchBoundary.signal.reason);
|
1601
1601
|
return;
|
1602
1602
|
}
|
1603
1603
|
if (body === bodyEnd) {
|
@@ -1635,7 +1635,7 @@ function tryCatch(renderBody, renderCatch) {
|
|
1635
1635
|
}
|
1636
1636
|
const catchChunk = new Chunk(boundary, null, chunk.context);
|
1637
1637
|
catchChunk.reorderId = reorderId;
|
1638
|
-
catchChunk.render(
|
1638
|
+
catchChunk.render(catchContent, catchBoundary.signal.reason);
|
1639
1639
|
state.reorder(catchChunk);
|
1640
1640
|
boundary.endAsync();
|
1641
1641
|
} else if (catchBoundary.done) {
|
@@ -1818,11 +1818,11 @@ var Chunk = class {
|
|
1818
1818
|
}
|
1819
1819
|
return cur;
|
1820
1820
|
}
|
1821
|
-
render(
|
1821
|
+
render(content, val) {
|
1822
1822
|
const prev = $chunk;
|
1823
1823
|
$chunk = this;
|
1824
1824
|
try {
|
1825
|
-
|
1825
|
+
content(val);
|
1826
1826
|
return $chunk;
|
1827
1827
|
} catch (err) {
|
1828
1828
|
this.boundary.abort(err);
|
@@ -2035,7 +2035,7 @@ function optionValueAttr(value) {
|
|
2035
2035
|
return attr("value", value) + (!isVoid(value) && (Array.isArray(value) ? selectedValue.includes(value) : selectedValue === value) ? ` selected` : "");
|
2036
2036
|
}
|
2037
2037
|
var kSelectedValue = Symbol("selectedValue");
|
2038
|
-
function controllable_select_value(scopeId, nodeAccessor, value, valueChange,
|
2038
|
+
function controllable_select_value(scopeId, nodeAccessor, value, valueChange, content) {
|
2039
2039
|
if (valueChange) {
|
2040
2040
|
writeControlledScope(
|
2041
2041
|
3 /* SelectValue */,
|
@@ -2045,8 +2045,8 @@ function controllable_select_value(scopeId, nodeAccessor, value, valueChange, re
|
|
2045
2045
|
valueChange
|
2046
2046
|
);
|
2047
2047
|
}
|
2048
|
-
if (
|
2049
|
-
withContext(kSelectedValue, value,
|
2048
|
+
if (content) {
|
2049
|
+
withContext(kSelectedValue, value, content);
|
2050
2050
|
}
|
2051
2051
|
}
|
2052
2052
|
function controllable_textarea_value(scopeId, nodeAccessor, value, valueChange) {
|
@@ -2182,7 +2182,7 @@ function attrs(data, nodeAccessor, scopeId, tagName) {
|
|
2182
2182
|
result += styleAttr(val);
|
2183
2183
|
break;
|
2184
2184
|
case "":
|
2185
|
-
case "
|
2185
|
+
case "content":
|
2186
2186
|
break;
|
2187
2187
|
default:
|
2188
2188
|
if (!isVoid(val)) {
|
@@ -2260,13 +2260,13 @@ var DEFAULT_RENDER_ID = "_";
|
|
2260
2260
|
|
2261
2261
|
// src/html/dynamic-tag.ts
|
2262
2262
|
var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
|
2263
|
-
function dynamicTagInput(scope, tag, input,
|
2264
|
-
if (!tag && !
|
2263
|
+
function dynamicTagInput(scope, tag, input, content, tagVar) {
|
2264
|
+
if (!tag && !content) return void 0;
|
2265
2265
|
const scopeId = getScopeId(scope);
|
2266
2266
|
write(`${markResumeScopeStart(scopeId)}`);
|
2267
2267
|
writeScope(scopeId, scope);
|
2268
2268
|
if (!tag) {
|
2269
|
-
return
|
2269
|
+
return content();
|
2270
2270
|
}
|
2271
2271
|
if (typeof tag === "string") {
|
2272
2272
|
nextScopeId();
|
@@ -2275,9 +2275,9 @@ function dynamicTagInput(scope, tag, input, renderBody, tagVar) {
|
|
2275
2275
|
);
|
2276
2276
|
if (!voidElementsReg.test(tag)) {
|
2277
2277
|
if (tag === "textarea") {
|
2278
|
-
if (
|
2278
|
+
if (content) {
|
2279
2279
|
throw new Error(
|
2280
|
-
"A dynamic tag rendering a `<textarea>` cannot have
|
2280
|
+
"A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead."
|
2281
2281
|
);
|
2282
2282
|
}
|
2283
2283
|
write(
|
@@ -2288,24 +2288,22 @@ function dynamicTagInput(scope, tag, input, renderBody, tagVar) {
|
|
2288
2288
|
input.valueChange
|
2289
2289
|
)
|
2290
2290
|
);
|
2291
|
-
} else if (
|
2291
|
+
} else if (content) {
|
2292
2292
|
if (tag === "select" && ("value" in input || "valueChange" in input)) {
|
2293
2293
|
controllable_select_value(
|
2294
2294
|
scopeId,
|
2295
2295
|
true ? `#${tag}/0` : 0,
|
2296
2296
|
input.value,
|
2297
2297
|
input.valueChange,
|
2298
|
-
|
2298
|
+
content
|
2299
2299
|
);
|
2300
2300
|
} else {
|
2301
|
-
|
2301
|
+
content();
|
2302
2302
|
}
|
2303
2303
|
}
|
2304
2304
|
write(`</${tag}>`);
|
2305
|
-
} else if (
|
2306
|
-
throw new Error(
|
2307
|
-
`A renderBody was provided for a "${tag}" tag, which cannot have children.`
|
2308
|
-
);
|
2305
|
+
} else if (content) {
|
2306
|
+
throw new Error(`Body content is not supported for a "${tag}" tag.`);
|
2309
2307
|
}
|
2310
2308
|
return null;
|
2311
2309
|
}
|
@@ -2315,7 +2313,7 @@ function dynamicTagInput(scope, tag, input, renderBody, tagVar) {
|
|
2315
2313
|
throw new Error(`Invalid renderer passed for dynamic tag: ${tag}`);
|
2316
2314
|
}
|
2317
2315
|
}
|
2318
|
-
return renderer(
|
2316
|
+
return renderer(content ? { ...input, content } : input, tagVar);
|
2319
2317
|
}
|
2320
2318
|
function dynamicTagArgs(scope, tag, args) {
|
2321
2319
|
if (!tag) return void 0;
|
@@ -2392,13 +2390,20 @@ var compat = {
|
|
2392
2390
|
null,
|
2393
2391
|
null
|
2394
2392
|
);
|
2393
|
+
let normalizedInput = input;
|
2394
|
+
if ("renderBody" in input) {
|
2395
|
+
normalizedInput = {};
|
2396
|
+
for (const key in input) {
|
2397
|
+
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
2398
|
+
}
|
2399
|
+
}
|
2395
2400
|
head.render(() => {
|
2396
2401
|
if (willRerender) {
|
2397
2402
|
const scopeId = peekNextScopeId();
|
2398
2403
|
writeScope(scopeId, { m5c: component.id });
|
2399
2404
|
writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
|
2400
2405
|
}
|
2401
|
-
renderer(
|
2406
|
+
renderer(normalizedInput);
|
2402
2407
|
});
|
2403
2408
|
const asyncOut = classAPIOut.beginAsync();
|
2404
2409
|
(boundary.onNext = () => {
|