marko 6.3.15 → 6.3.17
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/LICENSE +21 -0
- package/dist/common/accessor.d.ts +1 -0
- package/dist/common/accessor.debug.d.ts +1 -0
- package/dist/common/errors.d.ts +2 -0
- package/dist/common/types.d.ts +0 -1
- package/dist/debug/dom.js +36 -16
- package/dist/debug/dom.mjs +36 -16
- package/dist/debug/html.js +42 -15
- package/dist/debug/html.mjs +42 -16
- package/dist/dom.js +14 -15
- package/dist/dom.mjs +14 -15
- package/dist/html/attrs.d.ts +1 -0
- package/dist/html.d.ts +1 -1
- package/dist/html.js +20 -11
- package/dist/html.mjs +20 -11
- package/dist/translator/core/class.d.ts +3 -0
- package/dist/translator/core/index.d.ts +1 -0
- package/dist/translator/index.d.ts +1 -0
- package/dist/translator/index.js +146 -136
- package/dist/translator/util/body-to-text-literal.d.ts +2 -2
- package/dist/translator/util/references.d.ts +1 -1
- package/dist/translator/util/signals.d.ts +0 -1
- package/dist/translator/util/to-first-expression-or-block.d.ts +1 -2
- package/dist/translator/util/walks.d.ts +1 -1
- package/dist/translator/util/writer.d.ts +1 -1
- package/package.json +11 -7
package/dist/translator/index.js
CHANGED
|
@@ -127,6 +127,7 @@ let AccessorProp$1 = /* @__PURE__ */ function(AccessorProp) {
|
|
|
127
127
|
AccessorProp["Id"] = "#Id";
|
|
128
128
|
AccessorProp["Load"] = "#Load";
|
|
129
129
|
AccessorProp["LoopKey"] = "#LoopKey";
|
|
130
|
+
AccessorProp["LoopIndex"] = "#LoopIndex";
|
|
130
131
|
AccessorProp["ParentBranch"] = "#ParentBranch";
|
|
131
132
|
AccessorProp["PendingEffects"] = "#PendingEffects";
|
|
132
133
|
AccessorProp["PendingRenders"] = "#PendingRenders";
|
|
@@ -878,6 +879,7 @@ let AccessorProp = /* @__PURE__ */ function(AccessorProp) {
|
|
|
878
879
|
AccessorProp["Id"] = "L";
|
|
879
880
|
AccessorProp["Load"] = "X";
|
|
880
881
|
AccessorProp["LoopKey"] = "M";
|
|
882
|
+
AccessorProp["LoopIndex"] = "I";
|
|
881
883
|
AccessorProp["ParentBranch"] = "N";
|
|
882
884
|
AccessorProp["PendingEffects"] = "J";
|
|
883
885
|
AccessorProp["PendingRenders"] = "W";
|
|
@@ -1146,62 +1148,67 @@ function analyzeTagNameType(tag, allowDynamic) {
|
|
|
1146
1148
|
}
|
|
1147
1149
|
function analyzeExpressionTagName(name, extra) {
|
|
1148
1150
|
const pending = [name];
|
|
1151
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1149
1152
|
let path;
|
|
1150
1153
|
let type;
|
|
1151
1154
|
let nullable = false;
|
|
1152
1155
|
let tagNameImported;
|
|
1153
1156
|
let tagNameLoad;
|
|
1154
|
-
while ((path = pending.pop()) && type !== 2)
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
if (path.
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
if (!binding) {
|
|
1172
|
-
type = 2;
|
|
1173
|
-
continue;
|
|
1174
|
-
}
|
|
1175
|
-
if (binding.kind === "module") {
|
|
1176
|
-
const decl = binding.path.parent;
|
|
1177
|
-
if (MARKO_FILE_REG.test(decl.source.value) && decl.specifiers.some((it) => _marko_compiler.types.isImportDefaultSpecifier(it))) {
|
|
1178
|
-
const resolvedImport = decl.extra?.tagImport || decl.source.value;
|
|
1179
|
-
if (type === void 0) {
|
|
1180
|
-
type = 1;
|
|
1181
|
-
tagNameImported = resolvedImport;
|
|
1182
|
-
tagNameLoad = decl.extra?.loadImport;
|
|
1183
|
-
} else if (type === 0) {
|
|
1184
|
-
type = 2;
|
|
1185
|
-
tagNameImported = void 0;
|
|
1186
|
-
} else if (tagNameImported !== resolvedImport) tagNameImported = void 0;
|
|
1187
|
-
} else type = 2;
|
|
1188
|
-
continue;
|
|
1189
|
-
}
|
|
1190
|
-
const bindingTag = binding.path;
|
|
1191
|
-
if (bindingTag.isMarkoTag() && binding.kind === "local") {
|
|
1192
|
-
const bindingTagName = bindingTag.get("name").node.value;
|
|
1193
|
-
if (bindingTagName === "const") {
|
|
1194
|
-
pending.push(bindingTag.get("attributes")[0].get("value"));
|
|
1157
|
+
while ((path = pending.pop()) && type !== 2) {
|
|
1158
|
+
if (seen.has(path.node)) continue;
|
|
1159
|
+
seen.add(path.node);
|
|
1160
|
+
if (path.isConditionalExpression()) {
|
|
1161
|
+
pending.push(path.get("consequent"));
|
|
1162
|
+
if (path.node.alternate) pending.push(path.get("alternate"));
|
|
1163
|
+
} else if (path.isLogicalExpression()) {
|
|
1164
|
+
if (path.node.operator === "&&") nullable = true;
|
|
1165
|
+
else pending.push(path.get("left"));
|
|
1166
|
+
pending.push(path.get("right"));
|
|
1167
|
+
} else if (path.isAssignmentExpression()) pending.push(path.get("right"));
|
|
1168
|
+
else if (path.isBinaryExpression()) type = path.node.operator !== "+" || type === void 0 || type === 0 ? 0 : 2;
|
|
1169
|
+
else if (path.isStringLiteral() || path.isTemplateLiteral()) type = type === void 0 || type === 0 ? 0 : 2;
|
|
1170
|
+
else if (path.isNullLiteral()) nullable = true;
|
|
1171
|
+
else if (path.isIdentifier()) {
|
|
1172
|
+
if (path.node.name === "undefined") {
|
|
1173
|
+
nullable = true;
|
|
1195
1174
|
continue;
|
|
1196
1175
|
}
|
|
1197
|
-
|
|
1176
|
+
const binding = path.scope.getBinding(path.node.name);
|
|
1177
|
+
if (!binding) {
|
|
1198
1178
|
type = 2;
|
|
1199
1179
|
continue;
|
|
1200
1180
|
}
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1181
|
+
if (binding.kind === "module") {
|
|
1182
|
+
const decl = binding.path.parent;
|
|
1183
|
+
if (MARKO_FILE_REG.test(decl.source.value) && decl.specifiers.some((it) => _marko_compiler.types.isImportDefaultSpecifier(it))) {
|
|
1184
|
+
const resolvedImport = decl.extra?.tagImport || decl.source.value;
|
|
1185
|
+
if (type === void 0) {
|
|
1186
|
+
type = 1;
|
|
1187
|
+
tagNameImported = resolvedImport;
|
|
1188
|
+
tagNameLoad = decl.extra?.loadImport;
|
|
1189
|
+
} else if (type === 0) {
|
|
1190
|
+
type = 2;
|
|
1191
|
+
tagNameImported = void 0;
|
|
1192
|
+
} else if (tagNameImported !== resolvedImport) tagNameImported = void 0;
|
|
1193
|
+
} else type = 2;
|
|
1194
|
+
continue;
|
|
1195
|
+
}
|
|
1196
|
+
const bindingTag = binding.path;
|
|
1197
|
+
if (bindingTag.isMarkoTag() && binding.kind === "local") {
|
|
1198
|
+
const bindingTagName = bindingTag.get("name").node.value;
|
|
1199
|
+
if (bindingTagName === "const") {
|
|
1200
|
+
pending.push(bindingTag.get("attributes")[0].get("value"));
|
|
1201
|
+
continue;
|
|
1202
|
+
}
|
|
1203
|
+
if (bindingTagName === "let") {
|
|
1204
|
+
type = 2;
|
|
1205
|
+
continue;
|
|
1206
|
+
}
|
|
1207
|
+
continue;
|
|
1208
|
+
}
|
|
1209
|
+
type = 2;
|
|
1210
|
+
} else type = 2;
|
|
1211
|
+
}
|
|
1205
1212
|
extra.tagNameType = type ?? 2;
|
|
1206
1213
|
extra.tagNameNullable = nullable;
|
|
1207
1214
|
if (type === 1 && tagNameImported) {
|
|
@@ -1475,9 +1482,10 @@ function finalizeFunctionRegistry() {
|
|
|
1475
1482
|
function canIgnoreRegister(markoRoot, exprRoot) {
|
|
1476
1483
|
return markoRoot.isMarkoPlaceholder() || markoRoot.isMarkoScriptlet() && (!markoRoot.node.static || markoRoot.node.target === "server") || markoRoot.isMarkoTag() && markoRoot.node.name == exprRoot.node || isMarkoAttribute(markoRoot) && (analyzeTagNameType(markoRoot.parentPath) === 0 && /^on[A-Z-]/.test(markoRoot.node.name) && !hasSpreadAttributeAfter(markoRoot) || isCoreTagName(markoRoot.parentPath, "script") || isCoreTagName(markoRoot.parentPath, "lifecycle") || isCoreTagName(markoRoot.parentPath, "for"));
|
|
1477
1484
|
}
|
|
1478
|
-
function getStaticDeclRefs(fnExtra, path, refs = /* @__PURE__ */ new Set()) {
|
|
1485
|
+
function getStaticDeclRefs(fnExtra, path, refs = /* @__PURE__ */ new Set(), seen = /* @__PURE__ */ new Set()) {
|
|
1479
1486
|
const decl = getDeclarationRoot(path);
|
|
1480
|
-
if (decl) {
|
|
1487
|
+
if (decl && !seen.has(decl.node)) {
|
|
1488
|
+
seen.add(decl.node);
|
|
1481
1489
|
const ids = decl.getOuterBindingIdentifiers();
|
|
1482
1490
|
if (ids) for (const name in ids) {
|
|
1483
1491
|
const binding = decl.scope.getBinding(name);
|
|
@@ -1488,7 +1496,7 @@ function getStaticDeclRefs(fnExtra, path, refs = /* @__PURE__ */ new Set()) {
|
|
|
1488
1496
|
const markoRoot = getMarkoRoot(exprRoot);
|
|
1489
1497
|
if (!markoRoot || canIgnoreRegister(markoRoot, exprRoot)) continue;
|
|
1490
1498
|
if (isStaticRoot(markoRoot)) {
|
|
1491
|
-
if (getStaticDeclRefs(fnExtra, ref, refs) === true) return true;
|
|
1499
|
+
if (getStaticDeclRefs(fnExtra, ref, refs, seen) === true) return true;
|
|
1492
1500
|
} else if (shouldAlwaysRegister(markoRoot)) return true;
|
|
1493
1501
|
else refs.add(exprRoot.node.extra ??= {});
|
|
1494
1502
|
}
|
|
@@ -1735,8 +1743,8 @@ const escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeS
|
|
|
1735
1743
|
function _escape_script(val) {
|
|
1736
1744
|
return val ? escapeScriptStr(val + "") : val === 0 ? "0" : "";
|
|
1737
1745
|
}
|
|
1738
|
-
const unsafeStyleReg =
|
|
1739
|
-
const escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C
|
|
1746
|
+
const unsafeStyleReg = /<(\/style)/gi;
|
|
1747
|
+
const escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C$1") : str;
|
|
1740
1748
|
function _escape_style(val) {
|
|
1741
1749
|
return val ? escapeStyleStr(val + "") : val === 0 ? "0" : "";
|
|
1742
1750
|
}
|
|
@@ -1832,11 +1840,14 @@ function _attr_option_value(value) {
|
|
|
1832
1840
|
const kSelectedValue = Symbol("selectedValue");
|
|
1833
1841
|
function _attr_select_value(scopeId, nodeAccessor, value, valueChange, content, serializeType) {
|
|
1834
1842
|
if (valueChange) writeControlledScope(3, scopeId, nodeAccessor, void 0, valueChange, serializeType);
|
|
1835
|
-
if (content) withContext(kSelectedValue, value, content);
|
|
1843
|
+
if (content) withContext(kSelectedValue, value ?? "", content);
|
|
1836
1844
|
}
|
|
1837
1845
|
function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
|
|
1838
1846
|
if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType);
|
|
1839
|
-
return
|
|
1847
|
+
return _textarea_value(value);
|
|
1848
|
+
}
|
|
1849
|
+
function _textarea_value(value) {
|
|
1850
|
+
return _escape(normalizeStrAttrValue(value));
|
|
1840
1851
|
}
|
|
1841
1852
|
function _attr_input_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
|
|
1842
1853
|
if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType);
|
|
@@ -1974,7 +1985,7 @@ function normalizedValueMatches(a, b) {
|
|
|
1974
1985
|
return false;
|
|
1975
1986
|
}
|
|
1976
1987
|
function normalizeStrAttrValue(value) {
|
|
1977
|
-
return value && value !== true
|
|
1988
|
+
return isNotVoid(value) && value !== true ? value + "" : "";
|
|
1978
1989
|
}
|
|
1979
1990
|
//#endregion
|
|
1980
1991
|
//#region src/html/dynamic-tag.ts
|
|
@@ -2119,16 +2130,8 @@ function getCompatRuntimeFile() {
|
|
|
2119
2130
|
//#endregion
|
|
2120
2131
|
//#region src/translator/util/setup-statements.ts
|
|
2121
2132
|
/**
|
|
2122
|
-
* Tracks
|
|
2123
|
-
*
|
|
2124
|
-
* Sites that key statements by an expression's resolved references register
|
|
2125
|
-
* the expression with `addSetupExpr`; sites that always target the setup
|
|
2126
|
-
* signal call `addSetupStatement`. Expressions that resolve references
|
|
2127
|
-
* through `mergeReferences` are covered centrally by `finalizeReferences`.
|
|
2128
|
-
*
|
|
2129
|
-
* This lets a template's analyze phase prove its setup export is a noop so
|
|
2130
|
-
* parent templates can skip importing and calling it. The proof is checked
|
|
2131
|
-
* when the template itself is translated (see `visitors/program/dom.ts`).
|
|
2133
|
+
* Tracks during analyze whether translate will add setup-signal statements, so a
|
|
2134
|
+
* template can prove its setup export is a noop and parents can skip calling it.
|
|
2132
2135
|
*/
|
|
2133
2136
|
const [getSetupInfo] = createSectionState("setupStatements", () => ({
|
|
2134
2137
|
forced: false,
|
|
@@ -2387,7 +2390,6 @@ const [getSteps] = createSectionState("steps", (section) => {
|
|
|
2387
2390
|
});
|
|
2388
2391
|
const walkCodeToName = {
|
|
2389
2392
|
[32]: "get",
|
|
2390
|
-
[36]: "inside",
|
|
2391
2393
|
[37]: "replace",
|
|
2392
2394
|
[38]: "endChild",
|
|
2393
2395
|
[47]: "beginChild",
|
|
@@ -2565,12 +2567,12 @@ function getSectionMetaIdentifiers(section) {
|
|
|
2565
2567
|
}
|
|
2566
2568
|
return meta;
|
|
2567
2569
|
}
|
|
2568
|
-
function markNode(path, nodeBinding, reason) {
|
|
2570
|
+
function markNode(path, nodeBinding, reason, deferred) {
|
|
2569
2571
|
if (nodeBinding.type !== 0) throw path.buildCodeFrameError("POTENTIAL MARKO BUG: Tried to mark a node that was not determined to need a mark during analyze.");
|
|
2570
2572
|
if (isOutputHTML()) {
|
|
2571
2573
|
if (reason) {
|
|
2572
2574
|
const section = getSection(path);
|
|
2573
|
-
writeTo(path)`${callRuntime("_el_resume", getScopeIdIdentifier(section), getScopeAccessorLiteral(nodeBinding), getSerializeGuard(section, reason, true))}`;
|
|
2575
|
+
writeTo(path, deferred)`${callRuntime("_el_resume", getScopeIdIdentifier(section), getScopeAccessorLiteral(nodeBinding), getSerializeGuard(section, reason, true))}`;
|
|
2574
2576
|
}
|
|
2575
2577
|
}
|
|
2576
2578
|
}
|
|
@@ -2812,16 +2814,9 @@ function simplifyFunction(fn) {
|
|
|
2812
2814
|
//#endregion
|
|
2813
2815
|
//#region src/translator/util/to-first-expression-or-block.ts
|
|
2814
2816
|
function toFirstExpressionOrBlock(stmts) {
|
|
2815
|
-
if (stmts.length === 1 && _marko_compiler.types.isExpressionStatement(stmts[0])) return
|
|
2817
|
+
if (stmts.length === 1 && _marko_compiler.types.isExpressionStatement(stmts[0])) return stmts[0].expression;
|
|
2816
2818
|
return _marko_compiler.types.blockStatement(stmts);
|
|
2817
2819
|
}
|
|
2818
|
-
function toParenthesizedExpressionIfNeeded(expr) {
|
|
2819
|
-
switch (expr.type) {
|
|
2820
|
-
case "ObjectExpression":
|
|
2821
|
-
case "AssignmentExpression": return _marko_compiler.types.parenthesizedExpression(expr);
|
|
2822
|
-
default: return expr;
|
|
2823
|
-
}
|
|
2824
|
-
}
|
|
2825
2820
|
//#endregion
|
|
2826
2821
|
//#region src/translator/util/signals.ts
|
|
2827
2822
|
const [getSignals] = createSectionState("signals", () => /* @__PURE__ */ new Map());
|
|
@@ -2898,7 +2893,6 @@ function getSignal(section, referencedBindings, name) {
|
|
|
2898
2893
|
build: void 0,
|
|
2899
2894
|
export: !!exportName,
|
|
2900
2895
|
hasSideEffect: !!(referencedBindings && (Array.isArray(referencedBindings) || referencedBindings.type === 0 || referencedBindings.type === 1 || referencedBindings.section !== section || referencedBindings.closureSections || referencedBindings.hoists)),
|
|
2901
|
-
hasDynamicSubscribers: false,
|
|
2902
2896
|
forcePersist: false,
|
|
2903
2897
|
inline: void 0,
|
|
2904
2898
|
extraArgs: void 0,
|
|
@@ -2928,7 +2922,7 @@ function getSignal(section, referencedBindings, name) {
|
|
|
2928
2922
|
const render = getSignalFn(signal);
|
|
2929
2923
|
const closureSignalBuilder = getClosureSignalBuilder(section);
|
|
2930
2924
|
if (closureSignalBuilder && !isDynamicClosure(section, closure)) return closureSignalBuilder(closure, render);
|
|
2931
|
-
return callRuntime("_closure_get", isOptimize() ? _marko_compiler.types.numericLiteral(getClosureAccessorId(closure)) : getScopeAccessorLiteral(closure, true), render, isImmediateOwner(section, closure) ? void 0 : _marko_compiler.types.arrowFunctionExpression([scopeIdentifier], getScopeExpression(section, closure.section)),
|
|
2925
|
+
return callRuntime("_closure_get", isOptimize() ? _marko_compiler.types.numericLiteral(getClosureAccessorId(closure)) : getScopeAccessorLiteral(closure, true), render, isImmediateOwner(section, closure) ? void 0 : _marko_compiler.types.arrowFunctionExpression([scopeIdentifier], getScopeExpression(section, closure.section)), underTryPlaceholder(section) ? _marko_compiler.types.stringLiteral(getResumeRegisterId(section, closure, "pending")) : void 0);
|
|
2932
2926
|
};
|
|
2933
2927
|
}
|
|
2934
2928
|
return signal;
|
|
@@ -3126,7 +3120,7 @@ function replaceNullishAndEmptyFunctionsWith0(args) {
|
|
|
3126
3120
|
args[i] = _marko_compiler.types.numericLiteral(0);
|
|
3127
3121
|
continue;
|
|
3128
3122
|
}
|
|
3129
|
-
if (body.length === 1 && _marko_compiler.types.isExpressionStatement(body[0])) arg.body =
|
|
3123
|
+
if (body.length === 1 && _marko_compiler.types.isExpressionStatement(body[0])) arg.body = body[0].expression;
|
|
3130
3124
|
}
|
|
3131
3125
|
if (finalLen === void 0) finalLen = i + 1;
|
|
3132
3126
|
}
|
|
@@ -3698,7 +3692,7 @@ function getRegisteredFnExpression(node) {
|
|
|
3698
3692
|
//#region src/translator/util/body-to-text-literal.ts
|
|
3699
3693
|
const kRawText = Symbol("raw text placeholder");
|
|
3700
3694
|
function bodyToTextLiteral(body) {
|
|
3701
|
-
return buildTextLiteral(body, toText,
|
|
3695
|
+
return buildTextLiteral(body, toText, true);
|
|
3702
3696
|
}
|
|
3703
3697
|
function bodyToRawTextLiteral(body) {
|
|
3704
3698
|
return buildTextLiteral(body, (value) => value, true);
|
|
@@ -3722,15 +3716,17 @@ function buildTextLiteral(body, coerce, bareSingle) {
|
|
|
3722
3716
|
const templateExpressions = [];
|
|
3723
3717
|
let currentQuasi = "";
|
|
3724
3718
|
let placeholderExtra;
|
|
3719
|
+
let singleValue;
|
|
3725
3720
|
for (const child of body.body) if (_marko_compiler.types.isMarkoText(child)) currentQuasi += child.value;
|
|
3726
3721
|
else if (_marko_compiler.types.isMarkoPlaceholder(child)) {
|
|
3727
3722
|
placeholderExtra ||= child.value.extra;
|
|
3728
3723
|
templateQuasis.push(templateElement(currentQuasi, false));
|
|
3729
3724
|
templateExpressions.push(coerce(child.value));
|
|
3725
|
+
singleValue = child.value;
|
|
3730
3726
|
currentQuasi = "";
|
|
3731
3727
|
}
|
|
3732
3728
|
if (templateExpressions.length) {
|
|
3733
|
-
if (bareSingle && templateExpressions.length === 1 && !currentQuasi && !templateQuasis[0].value.cooked) return
|
|
3729
|
+
if (bareSingle && templateExpressions.length === 1 && !currentQuasi && !templateQuasis[0].value.cooked && !_marko_compiler.types.isStringLiteral(singleValue)) return singleValue;
|
|
3734
3730
|
templateQuasis.push(templateElement(currentQuasi, true));
|
|
3735
3731
|
const literal = _marko_compiler.types.templateLiteral(templateQuasis, templateExpressions);
|
|
3736
3732
|
literal.extra = placeholderExtra;
|
|
@@ -3803,7 +3799,7 @@ var for_default = {
|
|
|
3803
3799
|
"step"
|
|
3804
3800
|
];
|
|
3805
3801
|
break;
|
|
3806
|
-
default: throw tag.buildCodeFrameError("The [`<for>` tag](https://markojs.com/docs/reference/core-tag#for) requires an `of=`, `in=`, or `
|
|
3802
|
+
default: throw tag.buildCodeFrameError("The [`<for>` tag](https://markojs.com/docs/reference/core-tag#for) requires an `of=`, `in=`, `to=`, or `until=` attribute.");
|
|
3807
3803
|
}
|
|
3808
3804
|
if (!isAttrTag) allowAttrs.push("by");
|
|
3809
3805
|
const keyAttr = tag.node.attributes.find((attr) => attr.type === "MarkoAttribute" && attr.name === "key");
|
|
@@ -4353,9 +4349,17 @@ var native_tag_default = {
|
|
|
4353
4349
|
let exprExtras;
|
|
4354
4350
|
for (let i = attributes.length; i--;) {
|
|
4355
4351
|
const attr = attributes[i];
|
|
4352
|
+
if (_marko_compiler.types.isMarkoAttribute(attr) && attr.name === "content" && tag.node.body.body.length) {
|
|
4353
|
+
dropNodes(attr.value);
|
|
4354
|
+
continue;
|
|
4355
|
+
}
|
|
4356
4356
|
const valueExtra = attr.value.extra ??= {};
|
|
4357
4357
|
if (_marko_compiler.types.isMarkoAttribute(attr)) {
|
|
4358
4358
|
if (seen[attr.name]) {
|
|
4359
|
+
(0, _marko_compiler_babel_utils.diagnosticWarn)(tag, {
|
|
4360
|
+
label: `The \`${attr.name}\` attribute is set more than once on \`<${tagName}>\`; only the last value is used.`,
|
|
4361
|
+
loc: attr.loc ?? void 0
|
|
4362
|
+
});
|
|
4359
4363
|
dropNodes(attr.value);
|
|
4360
4364
|
continue;
|
|
4361
4365
|
}
|
|
@@ -4397,7 +4401,7 @@ var native_tag_default = {
|
|
|
4397
4401
|
if (node.var || hasDynamicAttributes || hasEventHandlers || textPlaceholders || injectNonce || isDynamicControllable(relatedControllable)) {
|
|
4398
4402
|
const tagExtra = node.extra ??= {};
|
|
4399
4403
|
const tagSection = getOrCreateSection(tag);
|
|
4400
|
-
const nodeBinding = tagExtra[kNativeTagBinding] = createBinding("#" + tagName, 0, tagSection, void 0, void 0, void 0, void 0, !!node.var);
|
|
4404
|
+
const nodeBinding = tagExtra[kNativeTagBinding] = createBinding("#" + tagName.toLowerCase(), 0, tagSection, void 0, void 0, void 0, void 0, !!node.var);
|
|
4401
4405
|
if (hasEventHandlers) (0, _marko_compiler_babel_utils.getProgram)().node.extra.isInteractive = true;
|
|
4402
4406
|
if (spreadReferenceNodes) {
|
|
4403
4407
|
const isMergedSpread = !!relatedControllable;
|
|
@@ -4488,7 +4492,7 @@ var native_tag_default = {
|
|
|
4488
4492
|
spreadExpression = spreadIdentifier;
|
|
4489
4493
|
}
|
|
4490
4494
|
if (valueChange) writeAtStartOfBody = callRuntime("_attr_textarea_value", getScopeIdIdentifier(tagSection), visitAccessor, value, valueChange, staticControllable ? void 0 : _marko_compiler.types.numericLiteral(1));
|
|
4491
|
-
else if (value) writeAtStartOfBody = callRuntime("
|
|
4495
|
+
else if (value) writeAtStartOfBody = callRuntime("_textarea_value", value);
|
|
4492
4496
|
}
|
|
4493
4497
|
for (const attr of staticAttrs) {
|
|
4494
4498
|
const { name, value } = attr;
|
|
@@ -4548,7 +4552,7 @@ var native_tag_default = {
|
|
|
4548
4552
|
const tagName = getCanonicalTagName(tag);
|
|
4549
4553
|
const tagSection = getSection(tag);
|
|
4550
4554
|
const markerSerializeReason = !tagExtra[kSkipEndTag] && nodeBinding && getSerializeReason(tagSection, nodeBinding);
|
|
4551
|
-
const write = writeTo(tag,
|
|
4555
|
+
const write = writeTo(tag, tagName === "html" || !markerSerializeReason && tagName === "body");
|
|
4552
4556
|
if (tagExtra[kTagContentAttr]) flushBefore(tag);
|
|
4553
4557
|
if (selectArgs) {
|
|
4554
4558
|
if (!tagExtra[kSkipEndTag]) write`</${tagName}>`;
|
|
@@ -4562,7 +4566,7 @@ var native_tag_default = {
|
|
|
4562
4566
|
if (tagName === "head" && getMarkoOpts().linkAssets) write`${callRuntime("_flush_head")}`;
|
|
4563
4567
|
write`</${tagName}>`;
|
|
4564
4568
|
}
|
|
4565
|
-
if (markerSerializeReason) markNode(tag, nodeBinding, markerSerializeReason);
|
|
4569
|
+
if (markerSerializeReason) markNode(tag, nodeBinding, markerSerializeReason, tagName === "html");
|
|
4566
4570
|
tag.remove();
|
|
4567
4571
|
}
|
|
4568
4572
|
},
|
|
@@ -5067,7 +5071,7 @@ function getOptimizedOnlyChildNodeBinding(tag, section, branchSize = 1) {
|
|
|
5067
5071
|
if (getOnlyChildParentTagName(tag, branchSize)) {
|
|
5068
5072
|
const parentTag = getParentTag(tag).node;
|
|
5069
5073
|
const parentTagName = parentTag.name?.value;
|
|
5070
|
-
return (parentTag.extra ??= {})[kNativeTagBinding] ??= createBinding("#" + parentTagName, 0, section);
|
|
5074
|
+
return (parentTag.extra ??= {})[kNativeTagBinding] ??= createBinding("#" + parentTagName.toLowerCase(), 0, section);
|
|
5071
5075
|
} else return (tag.node.extra ??= {})[kNodeRef] ??= createBinding("#text", 0, section);
|
|
5072
5076
|
}
|
|
5073
5077
|
//#endregion
|
|
@@ -5256,7 +5260,7 @@ function flattenTextOnlyConditional(rootTag) {
|
|
|
5256
5260
|
if (node.body.attributeTags || !body.length) return;
|
|
5257
5261
|
const [attr] = node.attributes;
|
|
5258
5262
|
if (isCoreTagName(tag, "else")) {
|
|
5259
|
-
if (node.attributes.length) return;
|
|
5263
|
+
if (node.attributes.length > 1 || attr && (!_marko_compiler.types.isMarkoAttribute(attr) || attr.name !== "if")) return;
|
|
5260
5264
|
} else if (node.attributes.length !== 1 || !_marko_compiler.types.isMarkoAttribute(attr) || !attr.default) return;
|
|
5261
5265
|
for (const child of body) if (_marko_compiler.types.isMarkoText(child)) {
|
|
5262
5266
|
if (_escape(child.value) !== child.value) return;
|
|
@@ -5273,7 +5277,8 @@ function flattenTextOnlyConditional(rootTag) {
|
|
|
5273
5277
|
const branchTag = branches[i];
|
|
5274
5278
|
const text = bodyToRawTextLiteral(branchTag.node.body);
|
|
5275
5279
|
rawText ||= _marko_compiler.types.isTemplateLiteral(text);
|
|
5276
|
-
|
|
5280
|
+
const [conditionAttr] = branchTag.node.attributes;
|
|
5281
|
+
expr = conditionAttr ? _marko_compiler.types.conditionalExpression(conditionAttr.value, text, expr) : text;
|
|
5277
5282
|
}
|
|
5278
5283
|
for (let i = branches.length; i-- > 1;) branches[i].remove();
|
|
5279
5284
|
const placeholder = _marko_compiler.types.markoPlaceholder(expr, true);
|
|
@@ -5362,6 +5367,8 @@ function isRoot(tag) {
|
|
|
5362
5367
|
//#region src/translator/core/textarea.ts
|
|
5363
5368
|
function preAnalyze$1(tag) {
|
|
5364
5369
|
if (tag.node.body.body.length) {
|
|
5370
|
+
const [firstChild] = tag.node.body.body;
|
|
5371
|
+
if (firstChild.type === "MarkoText") firstChild.value = firstChild.value.replace(/^\r?\n/, "");
|
|
5365
5372
|
const parts = [];
|
|
5366
5373
|
for (const child of tag.node.body.body) if (child.type === "MarkoText" || child.type === "MarkoPlaceholder" && child.escape) parts.push(child.value);
|
|
5367
5374
|
else throw tag.hub.file.hub.buildError(child, "Unexpected content in textarea, only text and placeholders are supported.", SyntaxError);
|
|
@@ -5496,7 +5503,7 @@ function getChangeHandler(tag, attr) {
|
|
|
5496
5503
|
if (!existingChangedAttr) {
|
|
5497
5504
|
const bindingIdentifierPath = binding.path.getOuterBindingIdentifierPaths()[binding.identifier.name];
|
|
5498
5505
|
let changeAttrExpr = bindingIdentifierPath ? bindingIdentifierPath.parentPath === binding.path ? buildChangeHandlerFunction(attr.value, modifier) : bindingIdentifierPath.parentPath.isObjectProperty() ? getChangeHandlerFromObjectPattern(bindingIdentifierPath.parentPath) : void 0 : void 0;
|
|
5499
|
-
if (!changeAttrExpr) throw tag.hub.buildError(attr.value, "Unable to bind to value.");
|
|
5506
|
+
if (!changeAttrExpr) throw tag.hub.buildError(attr.value, bindingIdentifierPath?.parentPath?.isArrayPattern() ? `Cannot two-way bind to \`${attr.value.name}\` because it comes from array destructuring, which has no change handler. Use object destructuring or pass an explicit \`${changeAttrName}\` attribute.` : "Unable to bind to value.");
|
|
5500
5507
|
if (modifier && _marko_compiler.types.isIdentifier(changeAttrExpr)) changeAttrExpr = _marko_compiler.types.logicalExpression("&&", changeAttrExpr, buildModifierForwarder(_marko_compiler.types.cloneNode(changeAttrExpr), modifier));
|
|
5501
5508
|
const changeHandlerAttr = _marko_compiler.types.markoAttribute(changeAttrName, changeAttrExpr);
|
|
5502
5509
|
BINDING_CHANGE_HANDLER.set(binding.identifier, changeHandlerAttr);
|
|
@@ -5602,9 +5609,6 @@ function buildUndefined() {
|
|
|
5602
5609
|
//#endregion
|
|
5603
5610
|
//#region src/translator/visitors/program/index.ts
|
|
5604
5611
|
let scopeIdentifier;
|
|
5605
|
-
function isScopeIdentifier(node) {
|
|
5606
|
-
return node === scopeIdentifier;
|
|
5607
|
-
}
|
|
5608
5612
|
var program_default = {
|
|
5609
5613
|
migrate: {
|
|
5610
5614
|
enter(program) {
|
|
@@ -5922,7 +5926,7 @@ function analyzeParams(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
5922
5926
|
dropNodes(getAllTagReferenceNodes(tag.node));
|
|
5923
5927
|
return inputExpr;
|
|
5924
5928
|
}
|
|
5925
|
-
if (!propTree.props || tag.node.arguments?.some((node) => _marko_compiler.types.isSpreadElement(node))) {
|
|
5929
|
+
if (!propTree.props || propTree.rest || tag.node.arguments?.some((node) => _marko_compiler.types.isSpreadElement(node))) {
|
|
5926
5930
|
const extra = inputExpr.value = mergeReferences(section, tag.node, getAllTagReferenceNodes(tag.node));
|
|
5927
5931
|
setBindingDownstream(propTree.binding, extra);
|
|
5928
5932
|
return inputExpr;
|
|
@@ -5930,14 +5934,13 @@ function analyzeParams(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
5930
5934
|
const known = inputExpr.known = {};
|
|
5931
5935
|
let i = 0;
|
|
5932
5936
|
if (tag.node.arguments) for (const arg of tag.node.arguments) {
|
|
5933
|
-
if (
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
addSetupExpr(section, arg);
|
|
5937
|
+
if (propTree.props[i]) {
|
|
5938
|
+
const argValueExtra = arg.extra ??= {};
|
|
5939
|
+
known[i] = { value: argValueExtra };
|
|
5940
|
+
rootAttrExprs.add(argValueExtra);
|
|
5941
|
+
addSetupExpr(section, arg);
|
|
5942
|
+
} else dropNodes(arg);
|
|
5943
|
+
i++;
|
|
5941
5944
|
}
|
|
5942
5945
|
const attrPropsTree = propTree.props[i];
|
|
5943
5946
|
if (attrPropsTree) known[i] = analyzeAttrs(rootTagExtra, section, tag, attrPropsTree, rootAttrExprs);
|
|
@@ -6112,7 +6115,7 @@ function getSingleKnownSpread(attributes) {
|
|
|
6112
6115
|
};
|
|
6113
6116
|
}
|
|
6114
6117
|
function writeParamsToSignals(tag, propTree, importAlias, info) {
|
|
6115
|
-
if (!propTree.props || tag.node.arguments?.some((node) => _marko_compiler.types.isSpreadElement(node))) {
|
|
6118
|
+
if (!propTree.props || propTree.rest || tag.node.arguments?.some((node) => _marko_compiler.types.isSpreadElement(node))) {
|
|
6116
6119
|
const referencedBindings = tag.node.extra?.referencedBindings;
|
|
6117
6120
|
const tagInputIdentifier = info.getBindingIdentifier(propTree.binding, `${importAlias}_params`);
|
|
6118
6121
|
const translatedAttrs = translateAttrs(tag);
|
|
@@ -7210,8 +7213,7 @@ function getSectionInstancesAccessor(section) {
|
|
|
7210
7213
|
return section.sectionAccessor ? section.sectionAccessor.prefix + getScopeAccessor(section.sectionAccessor.binding) : getAccessorPrefix().ClosureScopes + section.id;
|
|
7211
7214
|
}
|
|
7212
7215
|
function getSectionInstancesAccessorLiteral(section) {
|
|
7213
|
-
|
|
7214
|
-
return accessor ? typeof accessor === "number" ? _marko_compiler.types.numericLiteral(accessor) : _marko_compiler.types.stringLiteral(accessor) : void 0;
|
|
7216
|
+
return _marko_compiler.types.stringLiteral(getSectionInstancesAccessor(section));
|
|
7215
7217
|
}
|
|
7216
7218
|
function getReadReplacement(node, signal) {
|
|
7217
7219
|
const { extra } = node;
|
|
@@ -7655,6 +7657,17 @@ var await_default = {
|
|
|
7655
7657
|
types: runtime_info_default.name + "/tags/await.d.marko"
|
|
7656
7658
|
};
|
|
7657
7659
|
//#endregion
|
|
7660
|
+
//#region src/translator/core/class.ts
|
|
7661
|
+
var class_default = {
|
|
7662
|
+
parse(tag) {
|
|
7663
|
+
throw tag.hub.buildError(tag.node.name, "class {} component blocks are no longer supported. Use <let> and <const> tags for state.");
|
|
7664
|
+
},
|
|
7665
|
+
parseOptions: {
|
|
7666
|
+
statement: true,
|
|
7667
|
+
rawOpenTag: true
|
|
7668
|
+
}
|
|
7669
|
+
};
|
|
7670
|
+
//#endregion
|
|
7658
7671
|
//#region src/translator/core/client.ts
|
|
7659
7672
|
var client_default = {
|
|
7660
7673
|
parse(tag) {
|
|
@@ -8246,9 +8259,7 @@ var script_default = {
|
|
|
8246
8259
|
if (isOutputDOM()) {
|
|
8247
8260
|
const isFunction = _marko_compiler.types.isFunctionExpression(value) || _marko_compiler.types.isArrowFunctionExpression(value);
|
|
8248
8261
|
let inlineBody = null;
|
|
8249
|
-
|
|
8250
|
-
if (isFunction) if (value.async || value.generator) referencesScope = traverseContains(value, isScopeIdentifier);
|
|
8251
|
-
else if (_marko_compiler.types.isBlockStatement(value.body)) {
|
|
8262
|
+
if (isFunction) if (value.async || value.generator) {} else if (_marko_compiler.types.isBlockStatement(value.body)) {
|
|
8252
8263
|
if (!traverseContains(value.body, isReturnStatement)) {
|
|
8253
8264
|
let hasDeclaration = false;
|
|
8254
8265
|
for (const child of value.body.body) if (_marko_compiler.types.isDeclaration(child)) {
|
|
@@ -8258,7 +8269,7 @@ var script_default = {
|
|
|
8258
8269
|
inlineBody = hasDeclaration ? value.body : value.body.body;
|
|
8259
8270
|
}
|
|
8260
8271
|
} else inlineBody = _marko_compiler.types.expressionStatement(value.body);
|
|
8261
|
-
addStatement("effect", section, referencedBindings, inlineBody || _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(value,
|
|
8272
|
+
addStatement("effect", section, referencedBindings, inlineBody || _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(value, [])));
|
|
8262
8273
|
} else addHTMLEffectCall(section, referencedBindings);
|
|
8263
8274
|
tag.remove();
|
|
8264
8275
|
} },
|
|
@@ -8570,6 +8581,7 @@ const cssGluedBefore = /[\w%]$/;
|
|
|
8570
8581
|
//#region src/translator/core/style.ts
|
|
8571
8582
|
const STYLE_EXT_REG = /^style((?:\.[a-zA-Z0-9$_-]+)+)?/;
|
|
8572
8583
|
const programStyleCounts = /* @__PURE__ */ new WeakMap();
|
|
8584
|
+
const programDynamicStyleNameCounts = /* @__PURE__ */ new WeakMap();
|
|
8573
8585
|
var style_default = {
|
|
8574
8586
|
analyze(tag) {
|
|
8575
8587
|
(0, _marko_compiler_babel_utils.assertNoArgs)(tag);
|
|
@@ -8616,25 +8628,14 @@ function analyzeDynamicStyle(tag, names) {
|
|
|
8616
8628
|
}
|
|
8617
8629
|
function collectDynamicStyleNames(tag) {
|
|
8618
8630
|
let names;
|
|
8619
|
-
let index = 0;
|
|
8620
8631
|
for (const child of tag.node.body.body) if (_marko_compiler.types.isMarkoPlaceholder(child)) {
|
|
8621
|
-
|
|
8622
|
-
|
|
8623
|
-
|
|
8624
|
-
|
|
8625
|
-
names.push(dynamicStyleName(tag, index++));
|
|
8632
|
+
const program = (0, _marko_compiler_babel_utils.getProgram)().node;
|
|
8633
|
+
const index = programDynamicStyleNameCounts.get(program) ?? 0;
|
|
8634
|
+
programDynamicStyleNameCounts.set(program, index + 1);
|
|
8635
|
+
(names ??= []).push(dynamicStyleName(tag, index));
|
|
8626
8636
|
} else if (!_marko_compiler.types.isMarkoText(child)) throw tag.hub.buildError(child, "The [`<style>` tag](https://markojs.com/docs/reference/core-tag#style) only supports text and `${...}` interpolations. For a native html [`<style>` tag](https://markojs.com/docs/reference/core-tag#style) use the `html-style` core tag instead.");
|
|
8627
8637
|
return names;
|
|
8628
8638
|
}
|
|
8629
|
-
function dynamicStyleNameOffset(tag) {
|
|
8630
|
-
const { start } = tag.node;
|
|
8631
|
-
let offset = 0;
|
|
8632
|
-
if (start != null) _marko_compiler.types.traverseFast((0, _marko_compiler_babel_utils.getProgram)().node, (node) => {
|
|
8633
|
-
const dynamicStyle = node.extra?.dynamicStyle;
|
|
8634
|
-
if (dynamicStyle && node.start != null && node.start < start) offset += dynamicStyle.names.length;
|
|
8635
|
-
});
|
|
8636
|
-
return offset;
|
|
8637
|
-
}
|
|
8638
8639
|
const styleNameUnsafeReg = /[^a-zA-Z0-9_]/g;
|
|
8639
8640
|
const encodeStyleNameChar = (c) => "-" + c.charCodeAt(0).toString(36);
|
|
8640
8641
|
function dynamicStyleName(tag, index) {
|
|
@@ -8718,9 +8719,8 @@ function buildStyleDecls(node) {
|
|
|
8718
8719
|
return normalizeStringExpression(parts);
|
|
8719
8720
|
}
|
|
8720
8721
|
/**
|
|
8721
|
-
* Resolves a `<style>` block's text
|
|
8722
|
-
*
|
|
8723
|
-
* `resolveVirtualDependency` hook.
|
|
8722
|
+
* Resolves a `<style>` block's text to its client-side import path by handing
|
|
8723
|
+
* the css to the configured `resolveVirtualDependency` hook.
|
|
8724
8724
|
*/
|
|
8725
8725
|
function getStyleImportPath(file, node, names) {
|
|
8726
8726
|
const { resolveVirtualDependency, sourceMaps } = file.markoOpts;
|
|
@@ -8861,6 +8861,7 @@ var core_default = {
|
|
|
8861
8861
|
taglibId: runtime_info_default.taglibId,
|
|
8862
8862
|
"<attrs>": attrs_default,
|
|
8863
8863
|
"<await>": await_default,
|
|
8864
|
+
"<class>": class_default,
|
|
8864
8865
|
"<client>": client_default,
|
|
8865
8866
|
"<const>": const_default,
|
|
8866
8867
|
"<debug>": debug_default,
|
|
@@ -9495,6 +9496,14 @@ function optionalValueToNode(value) {
|
|
|
9495
9496
|
const kDOMBinding = Symbol("dynamic tag dom binding");
|
|
9496
9497
|
const kChildOffsetScopeBinding = Symbol("custom tag scope offset");
|
|
9497
9498
|
const importedDynamicTagResume = /* @__PURE__ */ new WeakSet();
|
|
9499
|
+
const [getCompatRegistrations] = createProgramState(() => /* @__PURE__ */ new Set());
|
|
9500
|
+
function pushCompatRegistration(key, statement) {
|
|
9501
|
+
const keys = getCompatRegistrations();
|
|
9502
|
+
if (!keys.has(key)) {
|
|
9503
|
+
keys.add(key);
|
|
9504
|
+
(0, _marko_compiler_babel_utils.getProgram)().node.body.push(statement);
|
|
9505
|
+
}
|
|
9506
|
+
}
|
|
9498
9507
|
var dynamic_tag_default = {
|
|
9499
9508
|
analyze: { enter(tag) {
|
|
9500
9509
|
(0, _marko_compiler_babel_utils.assertAttributesOrArgs)(tag);
|
|
@@ -9575,32 +9584,33 @@ var dynamic_tag_default = {
|
|
|
9575
9584
|
if (_marko_compiler.types.isStringLiteral(tagExpression)) tagExpression = (0, _marko_compiler_babel_utils.importDefault)(tag.hub.file, getTagRelativePath(tag), tagExpression.value);
|
|
9576
9585
|
if (classTagTemplate) {
|
|
9577
9586
|
const preserveBoundary = !tagsSerializeReason && (classHydration === "descendant" || classHydration === "self" && !!classFile?.metadata.marko.hasComponentBrowser);
|
|
9578
|
-
if (isOutputHTML() ? serializeReason || classHydration : serializeReason) (
|
|
9587
|
+
if (isOutputHTML() ? serializeReason || classHydration : serializeReason) pushCompatRegistration(classFile.metadata.marko.id, isOutputHTML() ? _marko_compiler.types.markoScriptlet([_marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression((0, _marko_compiler_babel_utils.importNamed)(tag.hub.file, getCompatRuntimeFile(), "s"), [
|
|
9579
9588
|
_marko_compiler.types.stringLiteral(classFile.metadata.marko.id),
|
|
9580
9589
|
_marko_compiler.types.identifier(tagExpression.name),
|
|
9581
9590
|
...preserveBoundary ? [_marko_compiler.types.stringLiteral("preserve")] : []
|
|
9582
9591
|
]))], true) : _marko_compiler.types.expressionStatement(callRuntime("_resume", _marko_compiler.types.stringLiteral(classFile.metadata.marko.id), _marko_compiler.types.identifier(tagExpression.name))));
|
|
9583
|
-
} else
|
|
9592
|
+
} else {
|
|
9593
|
+
const rendererName = tagExpression.name;
|
|
9594
|
+
pushCompatRegistration(rendererName, _marko_compiler.types.markoScriptlet([_marko_compiler.types.expressionStatement(_marko_compiler.types.assignmentExpression("??=", _marko_compiler.types.memberExpression(_marko_compiler.types.identifier(rendererName), _marko_compiler.types.identifier("_")), _marko_compiler.types.identifier(rendererName)))], true));
|
|
9595
|
+
}
|
|
9584
9596
|
} else if (_marko_compiler.types.isStringLiteral(tagExpression)) tagExpression = (0, _marko_compiler_babel_utils.importDefault)(tag.hub.file, getTagRelativePath(tag), tagExpression.value);
|
|
9585
9597
|
const { properties, statements } = translateAttrs(tag, void 0, void 0, void 0, isClassAPI ? "renderBody" : "content");
|
|
9586
9598
|
const args = [];
|
|
9599
|
+
const contentProp = getTranslatedBodyContentProperty(properties);
|
|
9587
9600
|
let hasTagArgs = false;
|
|
9588
9601
|
if (node.arguments) {
|
|
9589
9602
|
hasTagArgs = true;
|
|
9590
9603
|
args.push(...node.arguments);
|
|
9591
9604
|
if (properties.length) args.push(propsToExpression(properties));
|
|
9592
|
-
} else {
|
|
9593
|
-
|
|
9594
|
-
|
|
9595
|
-
|
|
9596
|
-
args.push(propsToExpression(properties), contentProp.value);
|
|
9597
|
-
} else args.push(propsToExpression(properties));
|
|
9598
|
-
}
|
|
9605
|
+
} else if (contentProp) {
|
|
9606
|
+
properties.splice(properties.indexOf(contentProp), 1);
|
|
9607
|
+
args.push(propsToExpression(properties), contentProp.value);
|
|
9608
|
+
} else args.push(propsToExpression(properties));
|
|
9599
9609
|
if (isOutputHTML()) {
|
|
9600
9610
|
flushInto(tag);
|
|
9601
9611
|
writeHTMLResumeStatements(tag.get("body"));
|
|
9602
9612
|
const serializeArg = getSerializeGuard(tagSection, serializeReason, true);
|
|
9603
|
-
const dynamicTagExpr = hasTagArgs ? callRuntime("_dynamic_tag", getScopeIdIdentifier(tagSection), getScopeAccessorLiteral(nodeBinding), tagExpression, _marko_compiler.types.arrayExpression(args), _marko_compiler.types.numericLiteral(0), _marko_compiler.types.numericLiteral(1), serializeArg) : callRuntime("_dynamic_tag", getScopeIdIdentifier(tagSection), getScopeAccessorLiteral(nodeBinding), tagExpression, args[0], args[1] || (serializeArg ? _marko_compiler.types.numericLiteral(0) : void 0), serializeArg ? _marko_compiler.types.numericLiteral(0) : void 0, serializeArg);
|
|
9613
|
+
const dynamicTagExpr = hasTagArgs ? callRuntime("_dynamic_tag", getScopeIdIdentifier(tagSection), getScopeAccessorLiteral(nodeBinding), tagExpression, _marko_compiler.types.arrayExpression(args), contentProp ? contentProp.value : _marko_compiler.types.numericLiteral(0), _marko_compiler.types.numericLiteral(1), serializeArg) : callRuntime("_dynamic_tag", getScopeIdIdentifier(tagSection), getScopeAccessorLiteral(nodeBinding), tagExpression, args[0], args[1] || (serializeArg ? _marko_compiler.types.numericLiteral(0) : void 0), serializeArg ? _marko_compiler.types.numericLiteral(0) : void 0, serializeArg);
|
|
9604
9614
|
if (node.var) {
|
|
9605
9615
|
const dynamicScopeIdentifier = generateUidIdentifier(tag.get("name").toString() + "_scope");
|
|
9606
9616
|
const mutatesTagVar = !!(tag.node.var.type === "Identifier" && tag.scope.getBinding(tag.node.var.name)?.constantViolations.length);
|
|
@@ -5,6 +5,6 @@ declare module "@marko/compiler/dist/types" {
|
|
|
5
5
|
[kRawText]?: true;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
-
export declare function bodyToTextLiteral(body: t.MarkoTagBody): t.
|
|
9
|
-
export declare function bodyToRawTextLiteral(body: t.MarkoTagBody): t.
|
|
8
|
+
export declare function bodyToTextLiteral(body: t.MarkoTagBody): t.ArrayExpression | t.ArrowFunctionExpression | t.AssignmentExpression | t.AwaitExpression | t.BigIntLiteral | t.BinaryExpression | t.BindExpression | t.BooleanLiteral | t.CallExpression | t.ClassExpression | t.ConditionalExpression | t.DecimalLiteral | t.DoExpression | t.FunctionExpression | t.Identifier | t.Import | t.ImportExpression | t.JSXElement | t.JSXFragment | t.LogicalExpression | t.MemberExpression | t.MetaProperty | t.ModuleExpression | t.NewExpression | t.NullLiteral | t.NumericLiteral | t.ObjectExpression | t.OptionalCallExpression | t.OptionalMemberExpression | t.ParenthesizedExpression | t.PipelineBareFunction | t.PipelinePrimaryTopicReference | t.PipelineTopicExpression | t.RecordExpression | t.RegExpLiteral | t.SequenceExpression | t.StringLiteral | t.Super | t.TSAsExpression | t.TSInstantiationExpression | t.TSNonNullExpression | t.TSSatisfiesExpression | t.TSTypeAssertion | t.TaggedTemplateExpression | t.TemplateLiteral | t.ThisExpression | t.TopicReference | t.TupleExpression | t.TypeCastExpression | t.UnaryExpression | t.UpdateExpression | t.YieldExpression | t.MarkoParseError;
|
|
9
|
+
export declare function bodyToRawTextLiteral(body: t.MarkoTagBody): t.ArrayExpression | t.ArrowFunctionExpression | t.AssignmentExpression | t.AwaitExpression | t.BigIntLiteral | t.BinaryExpression | t.BindExpression | t.BooleanLiteral | t.CallExpression | t.ClassExpression | t.ConditionalExpression | t.DecimalLiteral | t.DoExpression | t.FunctionExpression | t.Identifier | t.Import | t.ImportExpression | t.JSXElement | t.JSXFragment | t.LogicalExpression | t.MemberExpression | t.MetaProperty | t.ModuleExpression | t.NewExpression | t.NullLiteral | t.NumericLiteral | t.ObjectExpression | t.OptionalCallExpression | t.OptionalMemberExpression | t.ParenthesizedExpression | t.PipelineBareFunction | t.PipelinePrimaryTopicReference | t.PipelineTopicExpression | t.RecordExpression | t.RegExpLiteral | t.SequenceExpression | t.StringLiteral | t.Super | t.TSAsExpression | t.TSInstantiationExpression | t.TSNonNullExpression | t.TSSatisfiesExpression | t.TSTypeAssertion | t.TaggedTemplateExpression | t.TemplateLiteral | t.ThisExpression | t.TopicReference | t.TupleExpression | t.TypeCastExpression | t.UnaryExpression | t.UpdateExpression | t.YieldExpression | t.MarkoParseError;
|
|
10
10
|
export declare function injectTextCoercion(expr: t.Expression): void;
|
|
@@ -154,7 +154,7 @@ export declare function getDebugName(binding: Binding): string;
|
|
|
154
154
|
export declare function getDebugNames(refs: ReferencedBindings): string;
|
|
155
155
|
export declare function getDebugNamesAsIdentifier(refs: ReferencedBindings): string;
|
|
156
156
|
export declare function getSectionInstancesAccessor(section: Section): string;
|
|
157
|
-
export declare function getSectionInstancesAccessorLiteral(section: Section): t.
|
|
157
|
+
export declare function getSectionInstancesAccessorLiteral(section: Section): t.StringLiteral;
|
|
158
158
|
export declare function getReadReplacement(node: t.Identifier | t.MemberExpression | t.OptionalMemberExpression, signal?: Signal): t.Expression | undefined;
|
|
159
159
|
export declare function isInvokeOnlyBinding(binding: Binding): boolean;
|
|
160
160
|
export declare function hasNonConstantPropertyAlias(ref: Binding): boolean;
|