marko 6.1.13 → 6.1.14
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/common/errors.d.ts +4 -1
- package/dist/common/helpers.d.ts +1 -0
- package/dist/debug/dom.js +139 -58
- package/dist/debug/dom.mjs +139 -58
- package/dist/debug/html.js +171 -89
- package/dist/debug/html.mjs +171 -89
- package/dist/dom.js +21 -21
- package/dist/dom.mjs +21 -21
- package/dist/html/writer.d.ts +1 -1
- package/dist/html.js +51 -44
- package/dist/html.mjs +51 -44
- package/dist/translator/index.js +63 -4
- package/dist/translator/util/normalize-string-expression.d.ts +1 -0
- package/package.json +1 -1
package/dist/debug/html.mjs
CHANGED
|
@@ -19,8 +19,132 @@ function* attrTagIterator() {
|
|
|
19
19
|
yield* this[rest];
|
|
20
20
|
}
|
|
21
21
|
//#endregion
|
|
22
|
+
//#region src/common/helpers.ts
|
|
23
|
+
const htmlAttrNameReg = /^[^a-z_]|[^a-z0-9._:-]/i;
|
|
24
|
+
const knownWrongAttrs = {
|
|
25
|
+
className: "class",
|
|
26
|
+
classList: "class",
|
|
27
|
+
htmlFor: "for",
|
|
28
|
+
acceptCharset: "accept-charset",
|
|
29
|
+
httpEquiv: "http-equiv",
|
|
30
|
+
defaultValue: "value",
|
|
31
|
+
defaultChecked: "checked",
|
|
32
|
+
dangerouslySetInnerHTML: "$!{html}",
|
|
33
|
+
key: "<for by>",
|
|
34
|
+
ref: "<tag/ref>",
|
|
35
|
+
"v-if": "<if>",
|
|
36
|
+
"v-else": "<else>",
|
|
37
|
+
"v-else-if": "<else if>",
|
|
38
|
+
"v-for": "<for>",
|
|
39
|
+
"v-show": "<if>",
|
|
40
|
+
"v-model": "value:=state",
|
|
41
|
+
"v-bind": "...attrs",
|
|
42
|
+
"v-html": "$!{html}",
|
|
43
|
+
"v-text": "${text}"
|
|
44
|
+
};
|
|
45
|
+
function getWrongAttrSuggestion(name) {
|
|
46
|
+
const exact = knownWrongAttrs[name];
|
|
47
|
+
if (exact) return exact;
|
|
48
|
+
const colon = name.indexOf(":");
|
|
49
|
+
if (colon > 0) {
|
|
50
|
+
const rest = name.slice(colon + 1);
|
|
51
|
+
switch (name.slice(0, colon)) {
|
|
52
|
+
case "class": return `class={ ${rest}: condition }`;
|
|
53
|
+
case "style": return `style={ ${rest}: value }`;
|
|
54
|
+
case "on":
|
|
55
|
+
case "v-on": return `on${rest.charAt(0).toUpperCase()}${rest.slice(1)}`;
|
|
56
|
+
case "bind":
|
|
57
|
+
case "v-model": return `${rest}:=state`;
|
|
58
|
+
case "v-bind": return rest;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function stringifyClassObject(name, value) {
|
|
63
|
+
return value ? name : "";
|
|
64
|
+
}
|
|
65
|
+
function stringifyStyleObject(name, value) {
|
|
66
|
+
return value || value === 0 ? name + ":" + value : "";
|
|
67
|
+
}
|
|
68
|
+
const toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
|
|
69
|
+
let str = "";
|
|
70
|
+
let sep = "";
|
|
71
|
+
let part;
|
|
72
|
+
if (val) if (typeof val !== "object") str += val;
|
|
73
|
+
else if (Array.isArray(val)) for (const v of val) {
|
|
74
|
+
part = toDelimitedString(v, delimiter, stringify);
|
|
75
|
+
if (part) {
|
|
76
|
+
str += sep + part;
|
|
77
|
+
sep = delimiter;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else for (const name in val) {
|
|
81
|
+
part = stringify(name, val[name]);
|
|
82
|
+
if (part) {
|
|
83
|
+
str += sep + part;
|
|
84
|
+
sep = delimiter;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return str;
|
|
88
|
+
};
|
|
89
|
+
function isEventHandler(name) {
|
|
90
|
+
return /^on[A-Z-]/.test(name);
|
|
91
|
+
}
|
|
92
|
+
function getEventHandlerName(name) {
|
|
93
|
+
return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
|
|
94
|
+
}
|
|
95
|
+
function isVoid(value) {
|
|
96
|
+
return value == null || value === false;
|
|
97
|
+
}
|
|
98
|
+
function isNotVoid(value) {
|
|
99
|
+
return value != null && value !== false;
|
|
100
|
+
}
|
|
101
|
+
function normalizeDynamicRenderer(value) {
|
|
102
|
+
if (value) {
|
|
103
|
+
if (typeof value === "string") return value;
|
|
104
|
+
const normalized = value.content || value.default || value;
|
|
105
|
+
if ("id" in normalized) return normalized;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
22
109
|
//#region src/common/errors.ts
|
|
23
110
|
const lowercaseEventHandlerReg = /^on[a-z]/;
|
|
111
|
+
function assertValidAttrValue(name, value) {
|
|
112
|
+
if (value && typeof value !== "string" && lowercaseEventHandlerReg.test(name)) throw new Error(`The \`${name}\` attribute must be a string or a falsey value (\`null\`, \`undefined\`, \`false\`, \`0\`, …), but received type "${typeof value}". To attach an event listener, use the \`on${name[2].toUpperCase()}${name.slice(3)}\` event handler instead.`);
|
|
113
|
+
if (typeof value === "function") {
|
|
114
|
+
if (name === "content" || /^on/i.test(name) || /Change$/.test(name)) return;
|
|
115
|
+
throw new Error(`The \`${name}\` attribute cannot be a function.`);
|
|
116
|
+
}
|
|
117
|
+
const unrenderable = describeUnrenderable(value);
|
|
118
|
+
if (unrenderable) throw new Error(`The \`${name}\` attribute cannot be ${unrenderable}.`);
|
|
119
|
+
}
|
|
120
|
+
function assertValidTextValue(value) {
|
|
121
|
+
const unrenderable = describeUnrenderable(value);
|
|
122
|
+
if (unrenderable) throw new Error(`Text content cannot be ${unrenderable}.`);
|
|
123
|
+
}
|
|
124
|
+
function describeUnrenderable(value) {
|
|
125
|
+
if (typeof value === "symbol") return "a symbol";
|
|
126
|
+
if (typeof value === "object" && value !== null) {
|
|
127
|
+
let stringified;
|
|
128
|
+
try {
|
|
129
|
+
stringified = `${value}`;
|
|
130
|
+
} catch {
|
|
131
|
+
stringified = "[object Object]";
|
|
132
|
+
}
|
|
133
|
+
if (/^\[object \w+\]$/.test(stringified)) return stringified === "[object Promise]" ? "a promise (use the `<await>` tag to render its resolved value)" : stringified === "[object Object]" ? "a plain object (it would render as `[object Object]`)" : `a value that renders as \`${stringified}\``;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function assertValidLoopKey(key, seenKeys) {
|
|
137
|
+
if (typeof key !== "string" && typeof key !== "number") throw new Error(`A \`<for>\` tag's \`by\` attribute must return a string or number for each item, but received ${key === null ? "null" : `type "${typeof key}"`}.`);
|
|
138
|
+
if (seenKeys) {
|
|
139
|
+
if (seenKeys.has(key)) throw new Error(`A \`<for>\` tag's \`by\` attribute must return a unique value for each item, but \`${key}\` was used more than once.`);
|
|
140
|
+
seenKeys.add(key);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function assertValidAttrName(name) {
|
|
144
|
+
if (htmlAttrNameReg.test(name)) throw new Error(`Invalid attribute name: ${JSON.stringify(name)}`);
|
|
145
|
+
const suggestion = getWrongAttrSuggestion(name);
|
|
146
|
+
if (suggestion) throw new Error(`\`${name}\` is not a valid attribute, did you mean \`${suggestion}\`?`);
|
|
147
|
+
}
|
|
24
148
|
function _el_read_error() {
|
|
25
149
|
throw new Error("Element references can only be read in scripts and event handlers.");
|
|
26
150
|
}
|
|
@@ -45,9 +169,6 @@ function assertExclusiveAttrs(attrs, onError = throwErr) {
|
|
|
45
169
|
if (exclusiveAttrs && exclusiveAttrs.length > 1) onError(`The attributes ${joinWithAnd(exclusiveAttrs)} are mutually exclusive.`);
|
|
46
170
|
}
|
|
47
171
|
}
|
|
48
|
-
function assertValidEventHandlerAttr(name, value) {
|
|
49
|
-
if (value && typeof value !== "string" && lowercaseEventHandlerReg.test(name)) throw new Error(`The \`${name}\` attribute must be a string or a falsey value (\`null\`, \`undefined\`, \`false\`, \`0\`, …), but received type "${typeof value}". To attach an event listener, use the \`on${name[2].toUpperCase()}${name.slice(3)}\` event handler instead.`);
|
|
50
|
-
}
|
|
51
172
|
function assertHandlerIsFunction(name, value) {
|
|
52
173
|
if (value && typeof value !== "function") throw new Error(`The \`${name}\` handler must be a function or a falsey value (\`null\`, \`undefined\`, \`false\`, \`0\`, …), but received type "${typeof value}".`);
|
|
53
174
|
}
|
|
@@ -71,27 +192,32 @@ const DYNAMIC_TAG_SCRIPT_REGISTER_ID = "_dynamicTagScript";
|
|
|
71
192
|
//#endregion
|
|
72
193
|
//#region src/html/content.ts
|
|
73
194
|
function _unescaped(val) {
|
|
195
|
+
assertValidTextValue(val);
|
|
74
196
|
return val ? val + "" : val === 0 ? "0" : "";
|
|
75
197
|
}
|
|
76
198
|
const unsafeXMLReg = /[<&]/g;
|
|
77
199
|
const replaceUnsafeXML = (c) => c === "&" ? "&" : "<";
|
|
78
200
|
const escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str;
|
|
79
201
|
function _escape(val) {
|
|
202
|
+
assertValidTextValue(val);
|
|
80
203
|
return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "";
|
|
81
204
|
}
|
|
82
205
|
const unsafeScriptReg = /<\/script/gi;
|
|
83
206
|
const escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C/script") : str;
|
|
84
207
|
function _escape_script(val) {
|
|
208
|
+
assertValidTextValue(val);
|
|
85
209
|
return val ? escapeScriptStr(val + "") : val === 0 ? "0" : "";
|
|
86
210
|
}
|
|
87
211
|
const unsafeStyleReg = /<\/style/gi;
|
|
88
212
|
const escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C/style") : str;
|
|
89
213
|
function _escape_style(val) {
|
|
214
|
+
assertValidTextValue(val);
|
|
90
215
|
return val ? escapeStyleStr(val + "") : val === 0 ? "0" : "";
|
|
91
216
|
}
|
|
92
217
|
const unsafeCommentReg = />/g;
|
|
93
218
|
const escapeCommentStr = (str) => unsafeCommentReg.test(str) ? str.replace(unsafeCommentReg, ">") : str;
|
|
94
219
|
function _escape_comment(val) {
|
|
220
|
+
assertValidTextValue(val);
|
|
95
221
|
return val ? escapeCommentStr(val + "") : val === 0 ? "0" : "";
|
|
96
222
|
}
|
|
97
223
|
//#endregion
|
|
@@ -1157,6 +1283,7 @@ function isCircular(parent, ref) {
|
|
|
1157
1283
|
}
|
|
1158
1284
|
function toObjectKey(name) {
|
|
1159
1285
|
if (name === "") return "\"\"";
|
|
1286
|
+
if (name === "__proto__") return "[\"__proto__\"]";
|
|
1160
1287
|
const startChar = name[0];
|
|
1161
1288
|
if (isDigit(startChar)) {
|
|
1162
1289
|
if (startChar === "0") {
|
|
@@ -1169,7 +1296,7 @@ function toObjectKey(name) {
|
|
|
1169
1296
|
}
|
|
1170
1297
|
function toAccess(accessor) {
|
|
1171
1298
|
const start = accessor[0];
|
|
1172
|
-
return start === "\"" || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
|
|
1299
|
+
return start === "[" ? accessor : start === "\"" || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
|
|
1173
1300
|
}
|
|
1174
1301
|
function quote(str, startPos) {
|
|
1175
1302
|
let result = "";
|
|
@@ -1311,55 +1438,6 @@ function patchIteratorNext(proto) {
|
|
|
1311
1438
|
proto.next[kTouchedIterator] = true;
|
|
1312
1439
|
}
|
|
1313
1440
|
//#endregion
|
|
1314
|
-
//#region src/common/helpers.ts
|
|
1315
|
-
const htmlAttrNameReg = /^[^a-z_]|[^a-z0-9._:-]/i;
|
|
1316
|
-
function stringifyClassObject(name, value) {
|
|
1317
|
-
return value ? name : "";
|
|
1318
|
-
}
|
|
1319
|
-
function stringifyStyleObject(name, value) {
|
|
1320
|
-
return value || value === 0 ? name + ":" + value : "";
|
|
1321
|
-
}
|
|
1322
|
-
const toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
|
|
1323
|
-
let str = "";
|
|
1324
|
-
let sep = "";
|
|
1325
|
-
let part;
|
|
1326
|
-
if (val) if (typeof val !== "object") str += val;
|
|
1327
|
-
else if (Array.isArray(val)) for (const v of val) {
|
|
1328
|
-
part = toDelimitedString(v, delimiter, stringify);
|
|
1329
|
-
if (part) {
|
|
1330
|
-
str += sep + part;
|
|
1331
|
-
sep = delimiter;
|
|
1332
|
-
}
|
|
1333
|
-
}
|
|
1334
|
-
else for (const name in val) {
|
|
1335
|
-
part = stringify(name, val[name]);
|
|
1336
|
-
if (part) {
|
|
1337
|
-
str += sep + part;
|
|
1338
|
-
sep = delimiter;
|
|
1339
|
-
}
|
|
1340
|
-
}
|
|
1341
|
-
return str;
|
|
1342
|
-
};
|
|
1343
|
-
function isEventHandler(name) {
|
|
1344
|
-
return /^on[A-Z-]/.test(name);
|
|
1345
|
-
}
|
|
1346
|
-
function getEventHandlerName(name) {
|
|
1347
|
-
return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
|
|
1348
|
-
}
|
|
1349
|
-
function isVoid(value) {
|
|
1350
|
-
return value == null || value === false;
|
|
1351
|
-
}
|
|
1352
|
-
function isNotVoid(value) {
|
|
1353
|
-
return value != null && value !== false;
|
|
1354
|
-
}
|
|
1355
|
-
function normalizeDynamicRenderer(value) {
|
|
1356
|
-
if (value) {
|
|
1357
|
-
if (typeof value === "string") return value;
|
|
1358
|
-
const normalized = value.content || value.default || value;
|
|
1359
|
-
if ("id" in normalized) return normalized;
|
|
1360
|
-
}
|
|
1361
|
-
}
|
|
1362
|
-
//#endregion
|
|
1363
1441
|
//#region src/common/for.ts
|
|
1364
1442
|
function forIn(obj, cb) {
|
|
1365
1443
|
for (const key in obj) cb(key, obj[key]);
|
|
@@ -1402,28 +1480,13 @@ function concat(opt, other) {
|
|
|
1402
1480
|
//#endregion
|
|
1403
1481
|
//#region src/html/for.ts
|
|
1404
1482
|
function forOfBy(by, item, index) {
|
|
1405
|
-
|
|
1406
|
-
const key = typeof by === "string" ? item[by] : by(item, index);
|
|
1407
|
-
if (typeof key !== "string" && typeof key !== "number") console.error(`A <for> tag's \`by\` attribute must return a string or number, but it returned:`, key);
|
|
1408
|
-
return key;
|
|
1409
|
-
}
|
|
1410
|
-
return index;
|
|
1483
|
+
return by ? typeof by === "string" ? item[by] : by(item, index) : index;
|
|
1411
1484
|
}
|
|
1412
1485
|
function forInBy(by, name, value) {
|
|
1413
|
-
|
|
1414
|
-
const key = by(name, value);
|
|
1415
|
-
if (typeof key !== "string" && typeof key !== "number") console.error(`A <for> tag's \`by\` attribute must return a string or number, but it returned:`, key);
|
|
1416
|
-
return key;
|
|
1417
|
-
}
|
|
1418
|
-
return name;
|
|
1486
|
+
return by ? by(name, value) : name;
|
|
1419
1487
|
}
|
|
1420
1488
|
function forStepBy(by, index) {
|
|
1421
|
-
|
|
1422
|
-
const key = by(index);
|
|
1423
|
-
if (typeof key !== "string" && typeof key !== "number") console.error(`A <for> tag's \`by\` attribute must return a string or number, but it returned:`, key);
|
|
1424
|
-
return key;
|
|
1425
|
-
}
|
|
1426
|
-
return index;
|
|
1489
|
+
return by ? by(index) : index;
|
|
1427
1490
|
}
|
|
1428
1491
|
//#endregion
|
|
1429
1492
|
//#region src/html/inlined-runtimes.debug.ts
|
|
@@ -1684,20 +1747,31 @@ function _for_in(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarke
|
|
|
1684
1747
|
}) : forIn(obj, cb), scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode);
|
|
1685
1748
|
}
|
|
1686
1749
|
function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
|
|
1687
|
-
forBranches(by, (each) =>
|
|
1688
|
-
|
|
1689
|
-
each(
|
|
1690
|
-
|
|
1750
|
+
forBranches(by, (each) => {
|
|
1751
|
+
let index = 0;
|
|
1752
|
+
return each ? forTo(to, from, step, (value) => {
|
|
1753
|
+
const itemKey = forStepBy(by, value);
|
|
1754
|
+
each(itemKey, itemKey === index++, () => cb(value));
|
|
1755
|
+
}) : forTo(to, from, step, cb);
|
|
1756
|
+
}, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode);
|
|
1691
1757
|
}
|
|
1692
1758
|
function _for_until(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
|
|
1693
|
-
forBranches(by, (each) =>
|
|
1694
|
-
|
|
1695
|
-
each(
|
|
1696
|
-
|
|
1759
|
+
forBranches(by, (each) => {
|
|
1760
|
+
let index = 0;
|
|
1761
|
+
return each ? forUntil(to, from, step, (value) => {
|
|
1762
|
+
const itemKey = forStepBy(by, value);
|
|
1763
|
+
each(itemKey, itemKey === index++, () => cb(value));
|
|
1764
|
+
}) : forUntil(to, from, step, cb);
|
|
1765
|
+
}, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode);
|
|
1697
1766
|
}
|
|
1698
1767
|
function forBranches(by, iterate, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
|
|
1768
|
+
var seenKeys = /* @__PURE__ */ new Set();
|
|
1699
1769
|
if (serializeBranch === 0) {
|
|
1700
|
-
iterate(
|
|
1770
|
+
if (by) iterate((itemKey, _sameAsIndex, render) => {
|
|
1771
|
+
assertValidLoopKey(itemKey, seenKeys);
|
|
1772
|
+
render();
|
|
1773
|
+
});
|
|
1774
|
+
else iterate(0);
|
|
1701
1775
|
writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, "");
|
|
1702
1776
|
return;
|
|
1703
1777
|
}
|
|
@@ -1706,13 +1780,9 @@ function forBranches(by, iterate, scopeId, accessor, serializeBranch, serializeM
|
|
|
1706
1780
|
const resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0);
|
|
1707
1781
|
let flushBranchIds = "";
|
|
1708
1782
|
let loopScopes;
|
|
1709
|
-
var seenKeys = /* @__PURE__ */ new Set();
|
|
1710
1783
|
iterate((itemKey, sameAsIndex, render) => {
|
|
1711
1784
|
const branchId = _peek_scope_id();
|
|
1712
|
-
if (by)
|
|
1713
|
-
if (seenKeys.has(itemKey)) console.error(`A <for> tag's \`by\` attribute must return a unique value for each item, but a duplicate was found matching:`, itemKey);
|
|
1714
|
-
seenKeys.add(itemKey);
|
|
1715
|
-
}
|
|
1785
|
+
if (by) assertValidLoopKey(itemKey, seenKeys);
|
|
1716
1786
|
if (resumeMarker) if (singleNode) flushBranchIds = " " + branchId + flushBranchIds;
|
|
1717
1787
|
else {
|
|
1718
1788
|
$chunk.writeHTML(state.mark("[", flushBranchIds));
|
|
@@ -2384,12 +2454,24 @@ function _attr_style(value) {
|
|
|
2384
2454
|
}
|
|
2385
2455
|
function _attr_option_value(value) {
|
|
2386
2456
|
const valueAttr = _attr("value", value);
|
|
2387
|
-
|
|
2457
|
+
if (normalizedValueMatches(getContext(kSelectedValue), value)) {
|
|
2458
|
+
{
|
|
2459
|
+
const matched = getContext(kSelectedValueMatched);
|
|
2460
|
+
if (matched) matched.value = true;
|
|
2461
|
+
}
|
|
2462
|
+
return valueAttr + " selected";
|
|
2463
|
+
}
|
|
2464
|
+
return valueAttr;
|
|
2388
2465
|
}
|
|
2389
2466
|
const kSelectedValue = Symbol("selectedValue");
|
|
2467
|
+
const kSelectedValueMatched = Symbol("selectedValueMatched");
|
|
2390
2468
|
function _attr_select_value(scopeId, nodeAccessor, value, valueChange, content) {
|
|
2391
2469
|
if (valueChange) writeControlledScope(3, scopeId, nodeAccessor, void 0, valueChange);
|
|
2392
|
-
if (content)
|
|
2470
|
+
if (content) if (valueChange) {
|
|
2471
|
+
const matched = { value: false };
|
|
2472
|
+
withContext(kSelectedValue, value, () => withContext(kSelectedValueMatched, matched, content));
|
|
2473
|
+
if (!matched.value && (Array.isArray(value) ? value.some((v) => normalizeStrAttrValue(v) !== "") : normalizeStrAttrValue(value) !== "")) console.error("A controlled `<select>`'s `value` has no matching `<option>`:", value);
|
|
2474
|
+
} else withContext(kSelectedValue, value, content);
|
|
2393
2475
|
}
|
|
2394
2476
|
function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange) {
|
|
2395
2477
|
if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange);
|
|
@@ -2428,7 +2510,6 @@ function _attr_nonce() {
|
|
|
2428
2510
|
return getChunk().boundary.state.nonceAttr;
|
|
2429
2511
|
}
|
|
2430
2512
|
function _attr(name, value) {
|
|
2431
|
-
assertValidEventHandlerAttr(name, value);
|
|
2432
2513
|
return isVoid(value) ? "" : nonVoidAttr(name, value);
|
|
2433
2514
|
}
|
|
2434
2515
|
function _attrs(data, nodeAccessor, scopeId, tagName) {
|
|
@@ -2473,7 +2554,7 @@ function _attrs(data, nodeAccessor, scopeId, tagName) {
|
|
|
2473
2554
|
break;
|
|
2474
2555
|
default:
|
|
2475
2556
|
if (name && !(isVoid(value) || skip.test(name) || name === "content" && tagName !== "meta")) {
|
|
2476
|
-
|
|
2557
|
+
assertValidAttrName(name);
|
|
2477
2558
|
if (isEventHandler(name)) {
|
|
2478
2559
|
if (!events) {
|
|
2479
2560
|
events = {};
|
|
@@ -2515,6 +2596,7 @@ function stringAttr(name, value) {
|
|
|
2515
2596
|
return value && " " + name + attrAssignment(value);
|
|
2516
2597
|
}
|
|
2517
2598
|
function nonVoidAttr(name, value) {
|
|
2599
|
+
assertValidAttrValue(name, value);
|
|
2518
2600
|
switch (typeof value) {
|
|
2519
2601
|
case "string": return " " + name + attrAssignment(value);
|
|
2520
2602
|
case "boolean": return " " + name;
|
package/dist/dom.js
CHANGED
|
@@ -118,26 +118,6 @@ function attrTags(first, attrs) {
|
|
|
118
118
|
function* attrTagIterator() {
|
|
119
119
|
yield this, yield* this[rest];
|
|
120
120
|
}
|
|
121
|
-
function _assert_hoist(value) {}
|
|
122
|
-
//#endregion
|
|
123
|
-
//#region src/common/for.ts
|
|
124
|
-
function forIn(obj, cb) {
|
|
125
|
-
for (let key in obj) cb(key, obj[key]);
|
|
126
|
-
}
|
|
127
|
-
function forOf(list, cb) {
|
|
128
|
-
if (list) {
|
|
129
|
-
let i = 0;
|
|
130
|
-
for (let item of list) cb(item, i++);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
function forTo(to, from, step, cb) {
|
|
134
|
-
let start = from || 0, delta = step || 1;
|
|
135
|
-
for (let steps = (to - start) / delta, i = 0; i <= steps; i++) cb(start + i * delta);
|
|
136
|
-
}
|
|
137
|
-
function forUntil(until, from, step, cb) {
|
|
138
|
-
let start = from || 0, delta = step || 1;
|
|
139
|
-
for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
|
|
140
|
-
}
|
|
141
121
|
//#endregion
|
|
142
122
|
//#region src/common/helpers.ts
|
|
143
123
|
function _call(fn, v) {
|
|
@@ -165,6 +145,26 @@ function normalizeDynamicRenderer(value) {
|
|
|
165
145
|
if ("a" in normalized) return normalized;
|
|
166
146
|
}
|
|
167
147
|
}
|
|
148
|
+
function _assert_hoist(value) {}
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/common/for.ts
|
|
151
|
+
function forIn(obj, cb) {
|
|
152
|
+
for (let key in obj) cb(key, obj[key]);
|
|
153
|
+
}
|
|
154
|
+
function forOf(list, cb) {
|
|
155
|
+
if (list) {
|
|
156
|
+
let i = 0;
|
|
157
|
+
for (let item of list) cb(item, i++);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function forTo(to, from, step, cb) {
|
|
161
|
+
let start = from || 0, delta = step || 1;
|
|
162
|
+
for (let steps = (to - start) / delta, i = 0; i <= steps; i++) cb(start + i * delta);
|
|
163
|
+
}
|
|
164
|
+
function forUntil(until, from, step, cb) {
|
|
165
|
+
let start = from || 0, delta = step || 1;
|
|
166
|
+
for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
|
|
167
|
+
}
|
|
168
168
|
//#endregion
|
|
169
169
|
//#region src/common/opt.ts
|
|
170
170
|
function toArray(opt) {
|
|
@@ -772,7 +772,7 @@ function _attrs_partial_content(scope, nodeAccessor, nextAttrs, skip) {
|
|
|
772
772
|
function attrsInternal(scope, nodeAccessor, nextAttrs) {
|
|
773
773
|
let el = scope[nodeAccessor], events = scope["I" + nodeAccessor], skip;
|
|
774
774
|
for (let name in events) events[name] = 0;
|
|
775
|
-
switch (el.tagName) {
|
|
775
|
+
switch (scope["F" + nodeAccessor] = 5, scope["E" + nodeAccessor] = 0, el.tagName) {
|
|
776
776
|
case "INPUT":
|
|
777
777
|
if ("checked" in nextAttrs || "checkedChange" in nextAttrs) _attr_input_checked(scope, nodeAccessor, nextAttrs.checked, nextAttrs.checkedChange);
|
|
778
778
|
else if ("checkedValue" in nextAttrs || "checkedValueChange" in nextAttrs) _attr_input_checkedValue(scope, nodeAccessor, nextAttrs.checkedValue, nextAttrs.checkedValueChange, nextAttrs.value);
|
package/dist/dom.mjs
CHANGED
|
@@ -117,26 +117,6 @@ function attrTags(first, attrs) {
|
|
|
117
117
|
function* attrTagIterator() {
|
|
118
118
|
yield this, yield* this[rest];
|
|
119
119
|
}
|
|
120
|
-
function _assert_hoist(value) {}
|
|
121
|
-
//#endregion
|
|
122
|
-
//#region src/common/for.ts
|
|
123
|
-
function forIn(obj, cb) {
|
|
124
|
-
for (let key in obj) cb(key, obj[key]);
|
|
125
|
-
}
|
|
126
|
-
function forOf(list, cb) {
|
|
127
|
-
if (list) {
|
|
128
|
-
let i = 0;
|
|
129
|
-
for (let item of list) cb(item, i++);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
function forTo(to, from, step, cb) {
|
|
133
|
-
let start = from || 0, delta = step || 1;
|
|
134
|
-
for (let steps = (to - start) / delta, i = 0; i <= steps; i++) cb(start + i * delta);
|
|
135
|
-
}
|
|
136
|
-
function forUntil(until, from, step, cb) {
|
|
137
|
-
let start = from || 0, delta = step || 1;
|
|
138
|
-
for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
|
|
139
|
-
}
|
|
140
120
|
//#endregion
|
|
141
121
|
//#region src/common/helpers.ts
|
|
142
122
|
function _call(fn, v) {
|
|
@@ -164,6 +144,26 @@ function normalizeDynamicRenderer(value) {
|
|
|
164
144
|
if ("a" in normalized) return normalized;
|
|
165
145
|
}
|
|
166
146
|
}
|
|
147
|
+
function _assert_hoist(value) {}
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/common/for.ts
|
|
150
|
+
function forIn(obj, cb) {
|
|
151
|
+
for (let key in obj) cb(key, obj[key]);
|
|
152
|
+
}
|
|
153
|
+
function forOf(list, cb) {
|
|
154
|
+
if (list) {
|
|
155
|
+
let i = 0;
|
|
156
|
+
for (let item of list) cb(item, i++);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function forTo(to, from, step, cb) {
|
|
160
|
+
let start = from || 0, delta = step || 1;
|
|
161
|
+
for (let steps = (to - start) / delta, i = 0; i <= steps; i++) cb(start + i * delta);
|
|
162
|
+
}
|
|
163
|
+
function forUntil(until, from, step, cb) {
|
|
164
|
+
let start = from || 0, delta = step || 1;
|
|
165
|
+
for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
|
|
166
|
+
}
|
|
167
167
|
//#endregion
|
|
168
168
|
//#region src/common/opt.ts
|
|
169
169
|
function toArray(opt) {
|
|
@@ -771,7 +771,7 @@ function _attrs_partial_content(scope, nodeAccessor, nextAttrs, skip) {
|
|
|
771
771
|
function attrsInternal(scope, nodeAccessor, nextAttrs) {
|
|
772
772
|
let el = scope[nodeAccessor], events = scope["I" + nodeAccessor], skip;
|
|
773
773
|
for (let name in events) events[name] = 0;
|
|
774
|
-
switch (el.tagName) {
|
|
774
|
+
switch (scope["F" + nodeAccessor] = 5, scope["E" + nodeAccessor] = 0, el.tagName) {
|
|
775
775
|
case "INPUT":
|
|
776
776
|
if ("checked" in nextAttrs || "checkedChange" in nextAttrs) _attr_input_checked(scope, nodeAccessor, nextAttrs.checked, nextAttrs.checkedChange);
|
|
777
777
|
else if ("checkedValue" in nextAttrs || "checkedValueChange" in nextAttrs) _attr_input_checkedValue(scope, nodeAccessor, nextAttrs.checkedValue, nextAttrs.checkedValueChange, nextAttrs.value);
|
package/dist/html/writer.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export declare function getScopeById(scopeId: number | undefined): ScopeInternal
|
|
|
40
40
|
export declare function _set_serialize_reason(reason: undefined | 0 | 1): void;
|
|
41
41
|
export declare function _scope_reason(): 0 | 1 | undefined;
|
|
42
42
|
export declare function _serialize_if(condition: undefined | 1 | Record<string, 1>, key: string): 1 | undefined;
|
|
43
|
-
export declare function _serialize_guard(condition: undefined | 1 | Record<string, 1>, key: string):
|
|
43
|
+
export declare function _serialize_guard(condition: undefined | 1 | Record<string, 1>, key: string): 0 | 1;
|
|
44
44
|
export declare function _el_resume(scopeId: number, accessor: Accessor, shouldResume?: 0 | 1): string;
|
|
45
45
|
export declare function _sep(shouldResume: 0 | 1): "" | "<!>";
|
|
46
46
|
export declare function _el(scopeId: number, id: string): () => void;
|
package/dist/html.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
let empty = [], rest = Symbol(),
|
|
1
|
+
let empty = [], rest = Symbol(), toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
|
|
2
|
+
let str = "", sep = "", part;
|
|
3
|
+
if (val) if (typeof val != "object") str += val;
|
|
4
|
+
else if (Array.isArray(val)) for (let v of val) part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
|
|
5
|
+
else for (let name in val) part = stringify(name, val[name]), part && (str += sep + part, sep = delimiter);
|
|
6
|
+
return str;
|
|
7
|
+
}, unsafeXMLReg = /[<&]/g, replaceUnsafeXML = (c) => c === "&" ? "&" : "<", escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str, unsafeScriptReg = /<\/script/gi, escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C/script") : str, unsafeStyleReg = /<\/style/gi, escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C/style") : str, unsafeCommentReg = />/g, escapeCommentStr = (str) => unsafeCommentReg.test(str) ? str.replace(unsafeCommentReg, ">") : str, K_SCOPE_ID = Symbol("Scope ID"), kTouchedIterator = Symbol.for("marko.touchedIterator"), { hasOwnProperty: hasOwnProperty$1 } = {}, Generator = (function* () {})().constructor, AsyncGenerator = (async function* () {})().constructor, REGISTRY = /* @__PURE__ */ new WeakMap(), KNOWN_SYMBOLS = (() => {
|
|
2
8
|
let KNOWN_SYMBOLS = /* @__PURE__ */ new Map();
|
|
3
9
|
for (let name of Object.getOwnPropertyNames(Symbol)) {
|
|
4
10
|
let symbol = Symbol[name];
|
|
@@ -232,13 +238,7 @@ let empty = [], rest = Symbol(), unsafeXMLReg = /[<&]/g, replaceUnsafeXML = (c)
|
|
|
232
238
|
[JSON, "JSON"],
|
|
233
239
|
[Math, "Math"],
|
|
234
240
|
[Reflect, "Reflect"]
|
|
235
|
-
]),
|
|
236
|
-
let str = "", sep = "", part;
|
|
237
|
-
if (val) if (typeof val != "object") str += val;
|
|
238
|
-
else if (Array.isArray(val)) for (let v of val) part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
|
|
239
|
-
else for (let name in val) part = stringify(name, val[name]), part && (str += sep + part, sep = delimiter);
|
|
240
|
-
return str;
|
|
241
|
-
}, $chunk, NOOP$2 = () => {}, kPendingContexts = Symbol("Pending Contexts"), kBranchId = Symbol("Branch Id"), kIsAsync = Symbol("Is Async"), writeScope = (scopeId, partialScope) => {
|
|
241
|
+
]), $chunk, NOOP$2 = () => {}, kPendingContexts = Symbol("Pending Contexts"), kBranchId = Symbol("Branch Id"), kIsAsync = Symbol("Is Async"), writeScope = (scopeId, partialScope) => {
|
|
242
242
|
let { state } = $chunk.boundary, target = $chunk.serializeState, scope = scopeWithId(state, scopeId), pending = target.writeScopes[scopeId];
|
|
243
243
|
return state.needsMainRuntime = !0, Object.assign(scope, partialScope), pending && pending !== partialScope ? Object.assign(pending, partialScope) : target.writeScopes[scopeId] = partialScope, target.flushScopes = !0, scope;
|
|
244
244
|
}, tick = globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask || ((cb) => Promise.resolve().then(cb)), tickQueue, kSelectedValue = Symbol("selectedValue"), checkedValuesRefs = /* @__PURE__ */ new WeakMap(), singleQuoteAttrReplacements = /'|&(?=#?\w+;)/g, doubleQuoteAttrReplacements = /"|&(?=#?\w+;)/g, needsQuotedAttr = /["'>\s]|&#?\w+;|\/$/g, voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/, _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, serializeReason) => {
|
|
@@ -368,6 +368,33 @@ function* attrTagIterator() {
|
|
|
368
368
|
yield this, yield* this[rest];
|
|
369
369
|
}
|
|
370
370
|
//#endregion
|
|
371
|
+
//#region src/common/helpers.ts
|
|
372
|
+
function stringifyClassObject(name, value) {
|
|
373
|
+
return value ? name : "";
|
|
374
|
+
}
|
|
375
|
+
function stringifyStyleObject(name, value) {
|
|
376
|
+
return value || value === 0 ? name + ":" + value : "";
|
|
377
|
+
}
|
|
378
|
+
function isEventHandler(name) {
|
|
379
|
+
return /^on[A-Z-]/.test(name);
|
|
380
|
+
}
|
|
381
|
+
function getEventHandlerName(name) {
|
|
382
|
+
return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
|
|
383
|
+
}
|
|
384
|
+
function isVoid(value) {
|
|
385
|
+
return value == null || value === !1;
|
|
386
|
+
}
|
|
387
|
+
function isNotVoid(value) {
|
|
388
|
+
return value != null && value !== !1;
|
|
389
|
+
}
|
|
390
|
+
function normalizeDynamicRenderer(value) {
|
|
391
|
+
if (value) {
|
|
392
|
+
if (typeof value == "string") return value;
|
|
393
|
+
let normalized = value.content || value.default || value;
|
|
394
|
+
if ("a" in normalized) return normalized;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
//#endregion
|
|
371
398
|
//#region src/common/errors.ts
|
|
372
399
|
function _el_read_error() {}
|
|
373
400
|
function _hoist_read_error() {}
|
|
@@ -845,6 +872,7 @@ function isCircular(parent, ref) {
|
|
|
845
872
|
}
|
|
846
873
|
function toObjectKey(name) {
|
|
847
874
|
if (name === "") return "\"\"";
|
|
875
|
+
if (name === "__proto__") return "[\"__proto__\"]";
|
|
848
876
|
let startChar = name[0];
|
|
849
877
|
if (isDigit(startChar)) {
|
|
850
878
|
if (startChar === "0") {
|
|
@@ -857,7 +885,7 @@ function toObjectKey(name) {
|
|
|
857
885
|
}
|
|
858
886
|
function toAccess(accessor) {
|
|
859
887
|
let start = accessor[0];
|
|
860
|
-
return start === "\"" || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
|
|
888
|
+
return start === "[" ? accessor : start === "\"" || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
|
|
861
889
|
}
|
|
862
890
|
function quote(str, startPos) {
|
|
863
891
|
let result = "", lastPos = 0;
|
|
@@ -966,33 +994,6 @@ function patchIteratorNext(proto) {
|
|
|
966
994
|
}, proto.next[kTouchedIterator] = !0;
|
|
967
995
|
}
|
|
968
996
|
//#endregion
|
|
969
|
-
//#region src/common/helpers.ts
|
|
970
|
-
function stringifyClassObject(name, value) {
|
|
971
|
-
return value ? name : "";
|
|
972
|
-
}
|
|
973
|
-
function stringifyStyleObject(name, value) {
|
|
974
|
-
return value || value === 0 ? name + ":" + value : "";
|
|
975
|
-
}
|
|
976
|
-
function isEventHandler(name) {
|
|
977
|
-
return /^on[A-Z-]/.test(name);
|
|
978
|
-
}
|
|
979
|
-
function getEventHandlerName(name) {
|
|
980
|
-
return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
|
|
981
|
-
}
|
|
982
|
-
function isVoid(value) {
|
|
983
|
-
return value == null || value === !1;
|
|
984
|
-
}
|
|
985
|
-
function isNotVoid(value) {
|
|
986
|
-
return value != null && value !== !1;
|
|
987
|
-
}
|
|
988
|
-
function normalizeDynamicRenderer(value) {
|
|
989
|
-
if (value) {
|
|
990
|
-
if (typeof value == "string") return value;
|
|
991
|
-
let normalized = value.content || value.default || value;
|
|
992
|
-
if ("a" in normalized) return normalized;
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
//#endregion
|
|
996
997
|
//#region src/common/for.ts
|
|
997
998
|
function forIn(obj, cb) {
|
|
998
999
|
for (let key in obj) cb(key, obj[key]);
|
|
@@ -1174,16 +1175,22 @@ function _for_in(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarke
|
|
|
1174
1175
|
}) : forIn(obj, cb), scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode);
|
|
1175
1176
|
}
|
|
1176
1177
|
function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
|
|
1177
|
-
forBranches(by, (each) =>
|
|
1178
|
-
let
|
|
1179
|
-
each(
|
|
1180
|
-
|
|
1178
|
+
forBranches(by, (each) => {
|
|
1179
|
+
let index = 0;
|
|
1180
|
+
return each ? forTo(to, from, step, (value) => {
|
|
1181
|
+
let itemKey = forStepBy(by, value);
|
|
1182
|
+
each(itemKey, itemKey === index++, () => cb(value));
|
|
1183
|
+
}) : forTo(to, from, step, cb);
|
|
1184
|
+
}, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode);
|
|
1181
1185
|
}
|
|
1182
1186
|
function _for_until(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
|
|
1183
|
-
forBranches(by, (each) =>
|
|
1184
|
-
let
|
|
1185
|
-
each(
|
|
1186
|
-
|
|
1187
|
+
forBranches(by, (each) => {
|
|
1188
|
+
let index = 0;
|
|
1189
|
+
return each ? forUntil(to, from, step, (value) => {
|
|
1190
|
+
let itemKey = forStepBy(by, value);
|
|
1191
|
+
each(itemKey, itemKey === index++, () => cb(value));
|
|
1192
|
+
}) : forUntil(to, from, step, cb);
|
|
1193
|
+
}, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode);
|
|
1187
1194
|
}
|
|
1188
1195
|
function forBranches(by, iterate, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
|
|
1189
1196
|
if (serializeBranch === 0) {
|