marko 6.1.13 → 6.1.15

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/html.js CHANGED
@@ -1,4 +1,10 @@
1
- let empty = [], rest = Symbol(), unsafeXMLReg = /[<&]/g, replaceUnsafeXML = (c) => c === "&" ? "&amp;" : "&lt;", 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, "&gt;") : 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 = (() => {
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 === "&" ? "&amp;" : "&lt;", 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, "&gt;") : 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
- ]), toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
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) => each ? forTo(to, from, step, (i) => {
1178
- let itemKey = forStepBy(by, i);
1179
- each(itemKey, itemKey === i, () => cb(i));
1180
- }) : forTo(to, from, step, cb), scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode);
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) => each ? forUntil(to, from, step, (i) => {
1184
- let itemKey = forStepBy(by, i);
1185
- each(itemKey, itemKey === i, () => cb(i));
1186
- }) : forUntil(to, from, step, cb), scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode);
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) {
package/dist/html.mjs CHANGED
@@ -1,4 +1,10 @@
1
- let empty = [], rest = Symbol(), unsafeXMLReg = /[<&]/g, replaceUnsafeXML = (c) => c === "&" ? "&amp;" : "&lt;", 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, "&gt;") : 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 = (() => {
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 === "&" ? "&amp;" : "&lt;", 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, "&gt;") : 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
- ]), toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
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) => {
@@ -367,6 +367,33 @@ function* attrTagIterator() {
367
367
  yield this, yield* this[rest];
368
368
  }
369
369
  //#endregion
370
+ //#region src/common/helpers.ts
371
+ function stringifyClassObject(name, value) {
372
+ return value ? name : "";
373
+ }
374
+ function stringifyStyleObject(name, value) {
375
+ return value || value === 0 ? name + ":" + value : "";
376
+ }
377
+ function isEventHandler(name) {
378
+ return /^on[A-Z-]/.test(name);
379
+ }
380
+ function getEventHandlerName(name) {
381
+ return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
382
+ }
383
+ function isVoid(value) {
384
+ return value == null || value === !1;
385
+ }
386
+ function isNotVoid(value) {
387
+ return value != null && value !== !1;
388
+ }
389
+ function normalizeDynamicRenderer(value) {
390
+ if (value) {
391
+ if (typeof value == "string") return value;
392
+ let normalized = value.content || value.default || value;
393
+ if ("a" in normalized) return normalized;
394
+ }
395
+ }
396
+ //#endregion
370
397
  //#region src/common/errors.ts
371
398
  function _el_read_error() {}
372
399
  function _hoist_read_error() {}
@@ -844,6 +871,7 @@ function isCircular(parent, ref) {
844
871
  }
845
872
  function toObjectKey(name) {
846
873
  if (name === "") return "\"\"";
874
+ if (name === "__proto__") return "[\"__proto__\"]";
847
875
  let startChar = name[0];
848
876
  if (isDigit(startChar)) {
849
877
  if (startChar === "0") {
@@ -856,7 +884,7 @@ function toObjectKey(name) {
856
884
  }
857
885
  function toAccess(accessor) {
858
886
  let start = accessor[0];
859
- return start === "\"" || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
887
+ return start === "[" ? accessor : start === "\"" || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
860
888
  }
861
889
  function quote(str, startPos) {
862
890
  let result = "", lastPos = 0;
@@ -965,33 +993,6 @@ function patchIteratorNext(proto) {
965
993
  }, proto.next[kTouchedIterator] = !0;
966
994
  }
967
995
  //#endregion
968
- //#region src/common/helpers.ts
969
- function stringifyClassObject(name, value) {
970
- return value ? name : "";
971
- }
972
- function stringifyStyleObject(name, value) {
973
- return value || value === 0 ? name + ":" + value : "";
974
- }
975
- function isEventHandler(name) {
976
- return /^on[A-Z-]/.test(name);
977
- }
978
- function getEventHandlerName(name) {
979
- return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
980
- }
981
- function isVoid(value) {
982
- return value == null || value === !1;
983
- }
984
- function isNotVoid(value) {
985
- return value != null && value !== !1;
986
- }
987
- function normalizeDynamicRenderer(value) {
988
- if (value) {
989
- if (typeof value == "string") return value;
990
- let normalized = value.content || value.default || value;
991
- if ("a" in normalized) return normalized;
992
- }
993
- }
994
- //#endregion
995
996
  //#region src/common/for.ts
996
997
  function forIn(obj, cb) {
997
998
  for (let key in obj) cb(key, obj[key]);
@@ -1173,16 +1174,22 @@ function _for_in(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarke
1173
1174
  }) : forIn(obj, cb), scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode);
1174
1175
  }
1175
1176
  function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1176
- forBranches(by, (each) => each ? forTo(to, from, step, (i) => {
1177
- let itemKey = forStepBy(by, i);
1178
- each(itemKey, itemKey === i, () => cb(i));
1179
- }) : forTo(to, from, step, cb), scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode);
1177
+ forBranches(by, (each) => {
1178
+ let index = 0;
1179
+ return each ? forTo(to, from, step, (value) => {
1180
+ let itemKey = forStepBy(by, value);
1181
+ each(itemKey, itemKey === index++, () => cb(value));
1182
+ }) : forTo(to, from, step, cb);
1183
+ }, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode);
1180
1184
  }
1181
1185
  function _for_until(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1182
- forBranches(by, (each) => each ? forUntil(to, from, step, (i) => {
1183
- let itemKey = forStepBy(by, i);
1184
- each(itemKey, itemKey === i, () => cb(i));
1185
- }) : forUntil(to, from, step, cb), scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode);
1186
+ forBranches(by, (each) => {
1187
+ let index = 0;
1188
+ return each ? forUntil(to, from, step, (value) => {
1189
+ let itemKey = forStepBy(by, value);
1190
+ each(itemKey, itemKey === index++, () => cb(value));
1191
+ }) : forUntil(to, from, step, cb);
1192
+ }, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode);
1186
1193
  }
1187
1194
  function forBranches(by, iterate, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1188
1195
  if (serializeBranch === 0) {
@@ -203,6 +203,44 @@ function isNullableExpr(expr) {
203
203
  //#region src/common/helpers.ts
204
204
  const htmlAttrNameReg = /^[^a-z_]|[^a-z0-9._:-]/i;
205
205
  const userAttrNameReg = /^[^a-z_$]|[^a-z0-9._:-]/i;
206
+ const knownWrongAttrs = {
207
+ className: "class",
208
+ classList: "class",
209
+ htmlFor: "for",
210
+ acceptCharset: "accept-charset",
211
+ httpEquiv: "http-equiv",
212
+ defaultValue: "value",
213
+ defaultChecked: "checked",
214
+ dangerouslySetInnerHTML: "$!{html}",
215
+ key: "<for by>",
216
+ ref: "<tag/ref>",
217
+ "v-if": "<if>",
218
+ "v-else": "<else>",
219
+ "v-else-if": "<else if>",
220
+ "v-for": "<for>",
221
+ "v-show": "<if>",
222
+ "v-model": "value:=state",
223
+ "v-bind": "...attrs",
224
+ "v-html": "$!{html}",
225
+ "v-text": "${text}"
226
+ };
227
+ function getWrongAttrSuggestion(name) {
228
+ const exact = knownWrongAttrs[name];
229
+ if (exact) return exact;
230
+ const colon = name.indexOf(":");
231
+ if (colon > 0) {
232
+ const rest = name.slice(colon + 1);
233
+ switch (name.slice(0, colon)) {
234
+ case "class": return `class={ ${rest}: condition }`;
235
+ case "style": return `style={ ${rest}: value }`;
236
+ case "on":
237
+ case "v-on": return `on${rest.charAt(0).toUpperCase()}${rest.slice(1)}`;
238
+ case "bind":
239
+ case "v-model": return `${rest}:=state`;
240
+ case "v-bind": return rest;
241
+ }
242
+ }
243
+ }
206
244
  function stringifyClassObject(name, value) {
207
245
  return value ? name : "";
208
246
  }
@@ -498,7 +536,7 @@ new Map([
498
536
  ]);
499
537
  function toAccess(accessor) {
500
538
  const start = accessor[0];
501
- return start === "\"" || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
539
+ return start === "[" ? accessor : start === "\"" || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
502
540
  }
503
541
  function patchIteratorNext(proto) {
504
542
  if (proto.next[kTouchedIterator]) return;
@@ -1918,7 +1956,8 @@ function _attr_style(value) {
1918
1956
  }
1919
1957
  function _attr_option_value(value) {
1920
1958
  const valueAttr = _attr("value", value);
1921
- return normalizedValueMatches(getContext(kSelectedValue), value) ? valueAttr + " selected" : valueAttr;
1959
+ if (normalizedValueMatches(getContext(kSelectedValue), value)) return valueAttr + " selected";
1960
+ return valueAttr;
1922
1961
  }
1923
1962
  const kSelectedValue = Symbol("selectedValue");
1924
1963
  function _attr_select_value(scopeId, nodeAccessor, value, valueChange, content) {
@@ -4119,7 +4158,7 @@ function bodyToTextLiteral(body) {
4119
4158
  }
4120
4159
  function templateElement(value, tail) {
4121
4160
  return _marko_compiler.types.templateElement({
4122
- raw: value.replace(/`/g, "\\`"),
4161
+ raw: escapeTemplateRaw(value),
4123
4162
  cooked: value
4124
4163
  }, tail);
4125
4164
  }
@@ -4180,6 +4219,8 @@ var native_tag_default = {
4180
4219
  continue;
4181
4220
  }
4182
4221
  seen[attr.name] = attr;
4222
+ assertValidNativeAttrName(tag, attr);
4223
+ assertNativeAttrValueType(tag, attr);
4183
4224
  if (injectNonce && attr.name === "nonce") injectNonce = false;
4184
4225
  if (isEventOrChangeHandler(attr.name)) assertNativeHandlerAttr(tag, attr);
4185
4226
  if (isEventHandler(attr.name)) {
@@ -4597,6 +4638,22 @@ function isInjectNonceTag(tagName) {
4597
4638
  default: return false;
4598
4639
  }
4599
4640
  }
4641
+ function assertValidNativeAttrName(tag, attr) {
4642
+ const suggestion = getWrongAttrSuggestion(attr.name);
4643
+ if (suggestion) throw tag.hub.buildError(attr.loc?.end && { loc: {
4644
+ start: attr.loc.start,
4645
+ end: {
4646
+ line: attr.loc.start.line,
4647
+ column: attr.loc.start.column + attr.name.length
4648
+ }
4649
+ } }, `\`${attr.name}\` is not a valid attribute, did you mean \`${suggestion}\`?`, Error);
4650
+ }
4651
+ function assertNativeAttrValueType(tag, attr) {
4652
+ const { name } = attr;
4653
+ if (name === "class" || name === "style" || name === "content" || isEventOrChangeHandler(name) || lowercaseEventHandlerReg.test(name)) return;
4654
+ if (_marko_compiler.types.isFunction(attr.value)) throw tag.hub.buildError(attr, `The \`${name}\` attribute cannot be a function.`, Error);
4655
+ if (_marko_compiler.types.isObjectExpression(attr.value)) throw tag.hub.buildError(attr, `The \`${name}\` attribute cannot be a plain object (it would render as \`[object Object]\`).`, Error);
4656
+ }
4600
4657
  function assertNativeHandlerAttr(tag, attr) {
4601
4658
  if ((0, _marko_compiler_babel_utils.computeNode)(attr.value)?.value) throw tag.hub.buildError(attr.value, `The \`${attr.name}\` ${isEventHandler(attr.name) ? "event handler" : "change handler"} on a [native tag](https://markojs.com/docs/reference/native-tag) must be a function or a falsey value (\`null\`, \`undefined\`, \`false\`, \`0\`, …).`, Error);
4602
4659
  }
@@ -7608,8 +7665,10 @@ var lifecycle_default = {
7608
7665
  (0, _marko_compiler_babel_utils.assertNoParams)(tag);
7609
7666
  assertNoBodyContent(tag);
7610
7667
  const { node } = tag;
7611
- const tagExtra = mergeReferences(getOrCreateSection(tag), tag.node, getAllTagReferenceNodes(tag.node));
7668
+ const section = getOrCreateSection(tag);
7669
+ const tagExtra = mergeReferences(section, tag.node, getAllTagReferenceNodes(tag.node));
7612
7670
  tagExtra.isEffect = true;
7671
+ section.hasAbortSignal = true;
7613
7672
  if (node.attributes.length === 0) throw tag.get("name").buildCodeFrameError("The [`<lifecycle>` tag](https://markojs.com/docs/reference/core-tag#lifecycle) requires at least one attribute.");
7614
7673
  for (const attr of node.attributes) if (_marko_compiler.types.isMarkoSpreadAttribute(attr)) throw tag.get("name").buildCodeFrameError("The [`<lifecycle>` tag](https://markojs.com/docs/reference/core-tag#lifecycle) does not support [`...spread` attributes](https://markojs.com/docs/reference/language#spread-attributes).");
7615
7674
  (0, _marko_compiler_babel_utils.getProgram)().node.extra.isInteractive = true;
@@ -1,3 +1,4 @@
1
1
  import { types as t } from "@marko/compiler";
2
2
  export default function normalizeStringExpression(parts: (string | t.Expression)[], useIife?: boolean): t.Expression | undefined;
3
3
  export declare function appendLiteral(arr: unknown[], str: string): void;
4
+ export declare function escapeTemplateRaw(raw: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.1.13",
3
+ "version": "6.1.15",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",