marko 6.3.17 → 6.3.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/debug/dom.js CHANGED
@@ -73,7 +73,12 @@ function stringifyStyleObject(name, value) {
73
73
  warnedStyleKeys.add(name);
74
74
  console.warn(`\`${name}\` is not a CSS property name; \`style\` object keys are written verbatim, so it renders as invalid CSS. Use \`${name.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase()).replace(/^ms-/, "-ms-")}\`.`);
75
75
  }
76
- return value || value === 0 ? name + ":" + value : "";
76
+ return value || value === 0 ? escapeStyleAttr(name) + ":" + escapeStyleAttr(value + "") : "";
77
+ }
78
+ const unsafeStyleAttrReg = /[\\;]/g;
79
+ const replaceUnsafeStyleAttr = (c) => c === ";" ? "\\3B " : "\\\\";
80
+ function escapeStyleAttr(str) {
81
+ return unsafeStyleAttrReg.test(str) ? str.replace(unsafeStyleAttrReg, replaceUnsafeStyleAttr) : str;
77
82
  }
78
83
  function escapeStyleValue(str) {
79
84
  let closers = "";
@@ -1105,7 +1110,7 @@ function _attr_select_value_script(scope, nodeAccessor) {
1105
1110
  syncControllableFormInput(el, hasSelectChanged, onChange);
1106
1111
  new MutationObserver(() => {
1107
1112
  const value = scope["ControlledValue:" + nodeAccessor];
1108
- if (Array.isArray(value) ? value.length !== el.selectedOptions.length || value.some((value, i) => value != el.selectedOptions[i].value) : el.value !== value) onChange();
1113
+ if (Array.isArray(value) ? value.length !== el.selectedOptions.length || value.some((_, i) => !value.includes(el.selectedOptions[i].value)) : el.value !== value) onChange();
1109
1114
  }).observe(el, {
1110
1115
  childList: true,
1111
1116
  subtree: true
@@ -71,7 +71,12 @@ function stringifyStyleObject(name, value) {
71
71
  warnedStyleKeys.add(name);
72
72
  console.warn(`\`${name}\` is not a CSS property name; \`style\` object keys are written verbatim, so it renders as invalid CSS. Use \`${name.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase()).replace(/^ms-/, "-ms-")}\`.`);
73
73
  }
74
- return value || value === 0 ? name + ":" + value : "";
74
+ return value || value === 0 ? escapeStyleAttr(name) + ":" + escapeStyleAttr(value + "") : "";
75
+ }
76
+ const unsafeStyleAttrReg = /[\\;]/g;
77
+ const replaceUnsafeStyleAttr = (c) => c === ";" ? "\\3B " : "\\\\";
78
+ function escapeStyleAttr(str) {
79
+ return unsafeStyleAttrReg.test(str) ? str.replace(unsafeStyleAttrReg, replaceUnsafeStyleAttr) : str;
75
80
  }
76
81
  function escapeStyleValue(str) {
77
82
  let closers = "";
@@ -1103,7 +1108,7 @@ function _attr_select_value_script(scope, nodeAccessor) {
1103
1108
  syncControllableFormInput(el, hasSelectChanged, onChange);
1104
1109
  new MutationObserver(() => {
1105
1110
  const value = scope["ControlledValue:" + nodeAccessor];
1106
- if (Array.isArray(value) ? value.length !== el.selectedOptions.length || value.some((value, i) => value != el.selectedOptions[i].value) : el.value !== value) onChange();
1111
+ if (Array.isArray(value) ? value.length !== el.selectedOptions.length || value.some((_, i) => !value.includes(el.selectedOptions[i].value)) : el.value !== value) onChange();
1107
1112
  }).observe(el, {
1108
1113
  childList: true,
1109
1114
  subtree: true
@@ -69,7 +69,12 @@ function stringifyStyleObject(name, value) {
69
69
  warnedStyleKeys.add(name);
70
70
  console.warn(`\`${name}\` is not a CSS property name; \`style\` object keys are written verbatim, so it renders as invalid CSS. Use \`${name.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase()).replace(/^ms-/, "-ms-")}\`.`);
71
71
  }
72
- return value || value === 0 ? name + ":" + value : "";
72
+ return value || value === 0 ? escapeStyleAttr(name) + ":" + escapeStyleAttr(value + "") : "";
73
+ }
74
+ const unsafeStyleAttrReg = /[\\;]/g;
75
+ const replaceUnsafeStyleAttr = (c) => c === ";" ? "\\3B " : "\\\\";
76
+ function escapeStyleAttr(str) {
77
+ return unsafeStyleAttrReg.test(str) ? str.replace(unsafeStyleAttrReg, replaceUnsafeStyleAttr) : str;
73
78
  }
74
79
  function escapeStyleValue(str) {
75
80
  let closers = "";
@@ -1056,9 +1061,17 @@ function writeError(state, val, ref) {
1056
1061
  }
1057
1062
  function writeAggregateError(state, val, ref) {
1058
1063
  state.buf.push("new AggregateError(");
1059
- if (!writeProp(state, val.errors, ref, "errors")) state.buf.push("[]");
1064
+ const inlined = writeProp(state, val.errors, ref, "errors");
1065
+ if (!inlined) state.buf.push("[]");
1060
1066
  if (val.message) state.buf.push("," + quote(val.message + "", 0) + ")");
1061
1067
  else state.buf.push(")");
1068
+ if (inlined) {
1069
+ const errorsRef = state.refs.get(val.errors);
1070
+ if (errorsRef?.id) {
1071
+ state.assigned.add(errorsRef);
1072
+ addAssignment(errorsRef, accessId(state, ref) + toAccess("errors"));
1073
+ }
1074
+ }
1062
1075
  return true;
1063
1076
  }
1064
1077
  function writeURL(state, val) {
@@ -1113,11 +1126,17 @@ function writeRequest(state, val, ref) {
1113
1126
  options += sep + "credentials:" + quote(val.credentials, 0);
1114
1127
  sep = ",";
1115
1128
  }
1116
- const headers = stringEntriesToHeadersInit(val.headers);
1117
- state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null));
1118
- if (headers) {
1119
- options += sep + "headers:" + headers;
1129
+ const seenHeaders = state.refs.get(val.headers);
1130
+ if (seenHeaders) {
1131
+ options += sep + "headers:" + ensureId(state, seenHeaders);
1120
1132
  sep = ",";
1133
+ } else {
1134
+ state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null));
1135
+ const headers = stringEntriesToHeadersInit(val.headers);
1136
+ if (headers) {
1137
+ options += sep + "headers:" + headers;
1138
+ sep = ",";
1139
+ }
1121
1140
  }
1122
1141
  if (val.integrity) {
1123
1142
  options += sep + "integrity:" + quote(val.integrity, 0);
@@ -1158,9 +1177,13 @@ function writeResponse(state, val, ref) {
1158
1177
  options += sep + "statusText:" + quote(val.statusText, 0);
1159
1178
  sep = ",";
1160
1179
  }
1161
- const headers = stringEntriesToHeadersInit(val.headers);
1162
- state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null));
1163
- if (headers) options += sep + "headers:" + headers;
1180
+ const seenHeaders = state.refs.get(val.headers);
1181
+ if (seenHeaders) options += sep + "headers:" + ensureId(state, seenHeaders);
1182
+ else {
1183
+ state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null));
1184
+ const headers = stringEntriesToHeadersInit(val.headers);
1185
+ if (headers) options += sep + "headers:" + headers;
1186
+ }
1164
1187
  if (!val.body || val.bodyUsed) state.buf.push("new Response" + (options ? "(null,{" + options + "})" : ""));
1165
1188
  else {
1166
1189
  state.buf.push("new Response(");
@@ -3160,7 +3183,7 @@ function writeTriggerScript(html, triggers) {
3160
3183
  default: return `(e=>e?.addEventListener("${trigger.type.slice(3)}",l,{once:1}))(document.querySelector(${JSON.stringify(trigger.selector)})||l())`;
3161
3184
  }
3162
3185
  });
3163
- writeScript(`((p,h,d,l=$=>d||p.after(new Range().createContextualFragment(d=h)))=>${exprs.length > 1 ? `{${exprs.join(";")}}` : exprs[0]})(document.currentScript,${htmlStr})`);
3186
+ writeScript(`((p,h,d,l=$=>{d||p.after(new Range().createContextualFragment(d=h))})=>${exprs.length > 1 ? `{${exprs.join(";")}}` : exprs[0]})(document.currentScript,${htmlStr})`);
3164
3187
  }
3165
3188
  function toObjectExpression(options) {
3166
3189
  let result = "{";
@@ -67,7 +67,12 @@ function stringifyStyleObject(name, value) {
67
67
  warnedStyleKeys.add(name);
68
68
  console.warn(`\`${name}\` is not a CSS property name; \`style\` object keys are written verbatim, so it renders as invalid CSS. Use \`${name.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase()).replace(/^ms-/, "-ms-")}\`.`);
69
69
  }
70
- return value || value === 0 ? name + ":" + value : "";
70
+ return value || value === 0 ? escapeStyleAttr(name) + ":" + escapeStyleAttr(value + "") : "";
71
+ }
72
+ const unsafeStyleAttrReg = /[\\;]/g;
73
+ const replaceUnsafeStyleAttr = (c) => c === ";" ? "\\3B " : "\\\\";
74
+ function escapeStyleAttr(str) {
75
+ return unsafeStyleAttrReg.test(str) ? str.replace(unsafeStyleAttrReg, replaceUnsafeStyleAttr) : str;
71
76
  }
72
77
  function escapeStyleValue(str) {
73
78
  let closers = "";
@@ -1054,9 +1059,17 @@ function writeError(state, val, ref) {
1054
1059
  }
1055
1060
  function writeAggregateError(state, val, ref) {
1056
1061
  state.buf.push("new AggregateError(");
1057
- if (!writeProp(state, val.errors, ref, "errors")) state.buf.push("[]");
1062
+ const inlined = writeProp(state, val.errors, ref, "errors");
1063
+ if (!inlined) state.buf.push("[]");
1058
1064
  if (val.message) state.buf.push("," + quote(val.message + "", 0) + ")");
1059
1065
  else state.buf.push(")");
1066
+ if (inlined) {
1067
+ const errorsRef = state.refs.get(val.errors);
1068
+ if (errorsRef?.id) {
1069
+ state.assigned.add(errorsRef);
1070
+ addAssignment(errorsRef, accessId(state, ref) + toAccess("errors"));
1071
+ }
1072
+ }
1060
1073
  return true;
1061
1074
  }
1062
1075
  function writeURL(state, val) {
@@ -1111,11 +1124,17 @@ function writeRequest(state, val, ref) {
1111
1124
  options += sep + "credentials:" + quote(val.credentials, 0);
1112
1125
  sep = ",";
1113
1126
  }
1114
- const headers = stringEntriesToHeadersInit(val.headers);
1115
- state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null));
1116
- if (headers) {
1117
- options += sep + "headers:" + headers;
1127
+ const seenHeaders = state.refs.get(val.headers);
1128
+ if (seenHeaders) {
1129
+ options += sep + "headers:" + ensureId(state, seenHeaders);
1118
1130
  sep = ",";
1131
+ } else {
1132
+ state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null));
1133
+ const headers = stringEntriesToHeadersInit(val.headers);
1134
+ if (headers) {
1135
+ options += sep + "headers:" + headers;
1136
+ sep = ",";
1137
+ }
1119
1138
  }
1120
1139
  if (val.integrity) {
1121
1140
  options += sep + "integrity:" + quote(val.integrity, 0);
@@ -1156,9 +1175,13 @@ function writeResponse(state, val, ref) {
1156
1175
  options += sep + "statusText:" + quote(val.statusText, 0);
1157
1176
  sep = ",";
1158
1177
  }
1159
- const headers = stringEntriesToHeadersInit(val.headers);
1160
- state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null));
1161
- if (headers) options += sep + "headers:" + headers;
1178
+ const seenHeaders = state.refs.get(val.headers);
1179
+ if (seenHeaders) options += sep + "headers:" + ensureId(state, seenHeaders);
1180
+ else {
1181
+ state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null));
1182
+ const headers = stringEntriesToHeadersInit(val.headers);
1183
+ if (headers) options += sep + "headers:" + headers;
1184
+ }
1162
1185
  if (!val.body || val.bodyUsed) state.buf.push("new Response" + (options ? "(null,{" + options + "})" : ""));
1163
1186
  else {
1164
1187
  state.buf.push("new Response(");
@@ -3158,7 +3181,7 @@ function writeTriggerScript(html, triggers) {
3158
3181
  default: return `(e=>e?.addEventListener("${trigger.type.slice(3)}",l,{once:1}))(document.querySelector(${JSON.stringify(trigger.selector)})||l())`;
3159
3182
  }
3160
3183
  });
3161
- writeScript(`((p,h,d,l=$=>d||p.after(new Range().createContextualFragment(d=h)))=>${exprs.length > 1 ? `{${exprs.join(";")}}` : exprs[0]})(document.currentScript,${htmlStr})`);
3184
+ writeScript(`((p,h,d,l=$=>{d||p.after(new Range().createContextualFragment(d=h))})=>${exprs.length > 1 ? `{${exprs.join(";")}}` : exprs[0]})(document.currentScript,${htmlStr})`);
3162
3185
  }
3163
3186
  function toObjectExpression(options) {
3164
3187
  let result = "{";
package/dist/dom.js CHANGED
@@ -1,4 +1,4 @@
1
- let empty = [], rest = Symbol(), toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
1
+ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeStyleAttr = (c) => c === ";" ? "\\3B " : "\\\\", toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
2
2
  let str = "", sep = "", part;
3
3
  if (val) if (typeof val != "object") str += val;
4
4
  else if (Array.isArray(val)) for (let v of val) part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
@@ -136,7 +136,10 @@ function stringifyClassObject(name, value) {
136
136
  return value ? name : "";
137
137
  }
138
138
  function stringifyStyleObject(name, value) {
139
- return value || value === 0 ? name + ":" + value : "";
139
+ return value || value === 0 ? escapeStyleAttr(name) + ":" + escapeStyleAttr(value + "") : "";
140
+ }
141
+ function escapeStyleAttr(str) {
142
+ return unsafeStyleAttrReg.test(str) ? str.replace(unsafeStyleAttrReg, replaceUnsafeStyleAttr) : str;
140
143
  }
141
144
  function escapeStyleValue(str) {
142
145
  let closers = "", result = str.replace(/[\\"'{};<>]|\/(?=\*)/g, (c) => c === "<" ? "\\3C " : c === ";" ? "\\3B " : c === "{" ? "\\7B " : "\\" + c);
@@ -691,7 +694,7 @@ function _attr_select_value_script(scope, nodeAccessor) {
691
694
  }
692
695
  syncControllableFormInput(el, hasSelectChanged, onChange), new MutationObserver(() => {
693
696
  let value = scope["G" + nodeAccessor];
694
- (Array.isArray(value) ? value.length !== el.selectedOptions.length || value.some((value, i) => value != el.selectedOptions[i].value) : el.value !== value) && onChange();
697
+ (Array.isArray(value) ? value.length !== el.selectedOptions.length || value.some((_, i) => !value.includes(el.selectedOptions[i].value)) : el.value !== value) && onChange();
695
698
  }).observe(el, {
696
699
  childList: !0,
697
700
  subtree: !0
package/dist/dom.mjs CHANGED
@@ -1,4 +1,4 @@
1
- let empty = [], rest = Symbol(), toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
1
+ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeStyleAttr = (c) => c === ";" ? "\\3B " : "\\\\", toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
2
2
  let str = "", sep = "", part;
3
3
  if (val) if (typeof val != "object") str += val;
4
4
  else if (Array.isArray(val)) for (let v of val) part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
@@ -135,7 +135,10 @@ function stringifyClassObject(name, value) {
135
135
  return value ? name : "";
136
136
  }
137
137
  function stringifyStyleObject(name, value) {
138
- return value || value === 0 ? name + ":" + value : "";
138
+ return value || value === 0 ? escapeStyleAttr(name) + ":" + escapeStyleAttr(value + "") : "";
139
+ }
140
+ function escapeStyleAttr(str) {
141
+ return unsafeStyleAttrReg.test(str) ? str.replace(unsafeStyleAttrReg, replaceUnsafeStyleAttr) : str;
139
142
  }
140
143
  function escapeStyleValue(str) {
141
144
  let closers = "", result = str.replace(/[\\"'{};<>]|\/(?=\*)/g, (c) => c === "<" ? "\\3C " : c === ";" ? "\\3B " : c === "{" ? "\\7B " : "\\" + c);
@@ -690,7 +693,7 @@ function _attr_select_value_script(scope, nodeAccessor) {
690
693
  }
691
694
  syncControllableFormInput(el, hasSelectChanged, onChange), new MutationObserver(() => {
692
695
  let value = scope["G" + nodeAccessor];
693
- (Array.isArray(value) ? value.length !== el.selectedOptions.length || value.some((value, i) => value != el.selectedOptions[i].value) : el.value !== value) && onChange();
696
+ (Array.isArray(value) ? value.length !== el.selectedOptions.length || value.some((_, i) => !value.includes(el.selectedOptions[i].value)) : el.value !== value) && onChange();
694
697
  }).observe(el, {
695
698
  childList: !0,
696
699
  subtree: !0
package/dist/html.js CHANGED
@@ -1,4 +1,4 @@
1
- let empty = [], rest = Symbol(), toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
1
+ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeStyleAttr = (c) => c === ";" ? "\\3B " : "\\\\", toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
2
2
  let str = "", sep = "", part;
3
3
  if (val) if (typeof val != "object") str += val;
4
4
  else if (Array.isArray(val)) for (let v of val) part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
@@ -381,7 +381,10 @@ function stringifyClassObject(name, value) {
381
381
  return value ? name : "";
382
382
  }
383
383
  function stringifyStyleObject(name, value) {
384
- return value || value === 0 ? name + ":" + value : "";
384
+ return value || value === 0 ? escapeStyleAttr(name) + ":" + escapeStyleAttr(value + "") : "";
385
+ }
386
+ function escapeStyleAttr(str) {
387
+ return unsafeStyleAttrReg.test(str) ? str.replace(unsafeStyleAttrReg, replaceUnsafeStyleAttr) : str;
385
388
  }
386
389
  function escapeStyleValue(str) {
387
390
  let closers = "", result = str.replace(/[\\"'{};<>]|\/(?=\*)/g, (c) => c === "<" ? "\\3C " : c === ";" ? "\\3B " : c === "{" ? "\\7B " : "\\" + c);
@@ -789,7 +792,13 @@ function writeError(state, val, ref) {
789
792
  return !0;
790
793
  }
791
794
  function writeAggregateError(state, val, ref) {
792
- return state.buf.push("new AggregateError("), writeProp(state, val.errors, ref, "errors") || state.buf.push("[]"), val.message ? state.buf.push("," + quote(val.message + "", 0) + ")") : state.buf.push(")"), !0;
795
+ state.buf.push("new AggregateError(");
796
+ let inlined = writeProp(state, val.errors, ref, "errors");
797
+ if (inlined || state.buf.push("[]"), val.message ? state.buf.push("," + quote(val.message + "", 0) + ")") : state.buf.push(")"), inlined) {
798
+ let errorsRef = state.refs.get(val.errors);
799
+ errorsRef?.id && (state.assigned.add(errorsRef), addAssignment(errorsRef, accessId(state, ref) + toAccess("errors")));
800
+ }
801
+ return !0;
793
802
  }
794
803
  function writeURL(state, val) {
795
804
  return state.buf.push("new URL(" + quote(val.toString(), 0) + ")"), !0;
@@ -815,14 +824,26 @@ function writeRequest(state, val, ref) {
815
824
  state.buf.push("new Request(" + quote(val.url, 0)), hasBody && (state.buf.push(",{body:"), writeProp(state, val.body, ref, "body") ? (state.buf.push(",duplex:\"half\""), sep = ",", bodySerialized = !0) : state.buf.pop());
816
825
  let options = "";
817
826
  val.cache !== "default" && (options += sep + "cache:" + quote(val.cache, 0), sep = ","), val.credentials !== "same-origin" && (options += sep + "credentials:" + quote(val.credentials, 0), sep = ",");
818
- let headers = stringEntriesToHeadersInit(val.headers);
819
- return state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null)), headers && (options += sep + "headers:" + headers, sep = ","), val.integrity && (options += sep + "integrity:" + quote(val.integrity, 0), sep = ","), val.keepalive && (options += sep + "keepalive:true", sep = ","), val.method !== "GET" && (options += sep + "method:" + quote(val.method, 0), sep = ","), val.mode !== "cors" && (options += sep + "mode:" + quote(val.mode, 0), sep = ","), val.redirect !== "follow" && (options += sep + "redirect:" + quote(val.redirect, 0), sep = ","), val.referrer !== "about:client" && (options += sep + "referrer:" + quote(val.referrer, 0), sep = ","), val.referrerPolicy && (options += sep + "referrerPolicy:" + quote(val.referrerPolicy, 0)), state.buf.push(bodySerialized ? options + "})" : options ? ",{" + options + "})" : ")"), !0;
827
+ let seenHeaders = state.refs.get(val.headers);
828
+ if (seenHeaders) options += sep + "headers:" + ensureId(state, seenHeaders), sep = ",";
829
+ else {
830
+ state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null));
831
+ let headers = stringEntriesToHeadersInit(val.headers);
832
+ headers && (options += sep + "headers:" + headers, sep = ",");
833
+ }
834
+ return val.integrity && (options += sep + "integrity:" + quote(val.integrity, 0), sep = ","), val.keepalive && (options += sep + "keepalive:true", sep = ","), val.method !== "GET" && (options += sep + "method:" + quote(val.method, 0), sep = ","), val.mode !== "cors" && (options += sep + "mode:" + quote(val.mode, 0), sep = ","), val.redirect !== "follow" && (options += sep + "redirect:" + quote(val.redirect, 0), sep = ","), val.referrer !== "about:client" && (options += sep + "referrer:" + quote(val.referrer, 0), sep = ","), val.referrerPolicy && (options += sep + "referrerPolicy:" + quote(val.referrerPolicy, 0)), state.buf.push(bodySerialized ? options + "})" : options ? ",{" + options + "})" : ")"), !0;
820
835
  }
821
836
  function writeResponse(state, val, ref) {
822
837
  let sep = "", options = "";
823
838
  val.status !== 200 && (options += "status:" + val.status, sep = ","), val.statusText && (options += sep + "statusText:" + quote(val.statusText, 0), sep = ",");
824
- let headers = stringEntriesToHeadersInit(val.headers);
825
- return state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null)), headers && (options += sep + "headers:" + headers), !val.body || val.bodyUsed ? state.buf.push("new Response" + (options ? "(null,{" + options + "})" : "")) : (state.buf.push("new Response("), state.buf.push((writeProp(state, val.body, ref, "body") ? "" : "null") + (options ? ",{" + options + "})" : ")"))), !0;
839
+ let seenHeaders = state.refs.get(val.headers);
840
+ if (seenHeaders) options += sep + "headers:" + ensureId(state, seenHeaders);
841
+ else {
842
+ state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null));
843
+ let headers = stringEntriesToHeadersInit(val.headers);
844
+ headers && (options += sep + "headers:" + headers);
845
+ }
846
+ return !val.body || val.bodyUsed ? state.buf.push("new Response" + (options ? "(null,{" + options + "})" : "")) : (state.buf.push("new Response("), state.buf.push((writeProp(state, val.body, ref, "body") ? "" : "null") + (options ? ",{" + options + "})" : ")"))), !0;
826
847
  }
827
848
  function writeReadableStream(state, val, ref) {
828
849
  let { boundary, channel } = state;
@@ -2055,7 +2076,7 @@ function writeTriggerScript(html, triggers) {
2055
2076
  default: return `(e=>e?.addEventListener("${trigger.type.slice(3)}",l,{once:1}))(document.querySelector(${JSON.stringify(trigger.selector)})||l())`;
2056
2077
  }
2057
2078
  });
2058
- writeScript(`((p,h,d,l=$=>d||p.after(new Range().createContextualFragment(d=h)))=>${exprs.length > 1 ? `{${exprs.join(";")}}` : exprs[0]})(document.currentScript,${htmlStr})`);
2079
+ writeScript(`((p,h,d,l=$=>{d||p.after(new Range().createContextualFragment(d=h))})=>${exprs.length > 1 ? `{${exprs.join(";")}}` : exprs[0]})(document.currentScript,${htmlStr})`);
2059
2080
  }
2060
2081
  function toObjectExpression(options) {
2061
2082
  let result = "{", sep = "";
package/dist/html.mjs CHANGED
@@ -1,4 +1,4 @@
1
- let empty = [], rest = Symbol(), toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
1
+ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeStyleAttr = (c) => c === ";" ? "\\3B " : "\\\\", toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
2
2
  let str = "", sep = "", part;
3
3
  if (val) if (typeof val != "object") str += val;
4
4
  else if (Array.isArray(val)) for (let v of val) part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
@@ -380,7 +380,10 @@ function stringifyClassObject(name, value) {
380
380
  return value ? name : "";
381
381
  }
382
382
  function stringifyStyleObject(name, value) {
383
- return value || value === 0 ? name + ":" + value : "";
383
+ return value || value === 0 ? escapeStyleAttr(name) + ":" + escapeStyleAttr(value + "") : "";
384
+ }
385
+ function escapeStyleAttr(str) {
386
+ return unsafeStyleAttrReg.test(str) ? str.replace(unsafeStyleAttrReg, replaceUnsafeStyleAttr) : str;
384
387
  }
385
388
  function escapeStyleValue(str) {
386
389
  let closers = "", result = str.replace(/[\\"'{};<>]|\/(?=\*)/g, (c) => c === "<" ? "\\3C " : c === ";" ? "\\3B " : c === "{" ? "\\7B " : "\\" + c);
@@ -788,7 +791,13 @@ function writeError(state, val, ref) {
788
791
  return !0;
789
792
  }
790
793
  function writeAggregateError(state, val, ref) {
791
- return state.buf.push("new AggregateError("), writeProp(state, val.errors, ref, "errors") || state.buf.push("[]"), val.message ? state.buf.push("," + quote(val.message + "", 0) + ")") : state.buf.push(")"), !0;
794
+ state.buf.push("new AggregateError(");
795
+ let inlined = writeProp(state, val.errors, ref, "errors");
796
+ if (inlined || state.buf.push("[]"), val.message ? state.buf.push("," + quote(val.message + "", 0) + ")") : state.buf.push(")"), inlined) {
797
+ let errorsRef = state.refs.get(val.errors);
798
+ errorsRef?.id && (state.assigned.add(errorsRef), addAssignment(errorsRef, accessId(state, ref) + toAccess("errors")));
799
+ }
800
+ return !0;
792
801
  }
793
802
  function writeURL(state, val) {
794
803
  return state.buf.push("new URL(" + quote(val.toString(), 0) + ")"), !0;
@@ -814,14 +823,26 @@ function writeRequest(state, val, ref) {
814
823
  state.buf.push("new Request(" + quote(val.url, 0)), hasBody && (state.buf.push(",{body:"), writeProp(state, val.body, ref, "body") ? (state.buf.push(",duplex:\"half\""), sep = ",", bodySerialized = !0) : state.buf.pop());
815
824
  let options = "";
816
825
  val.cache !== "default" && (options += sep + "cache:" + quote(val.cache, 0), sep = ","), val.credentials !== "same-origin" && (options += sep + "credentials:" + quote(val.credentials, 0), sep = ",");
817
- let headers = stringEntriesToHeadersInit(val.headers);
818
- return state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null)), headers && (options += sep + "headers:" + headers, sep = ","), val.integrity && (options += sep + "integrity:" + quote(val.integrity, 0), sep = ","), val.keepalive && (options += sep + "keepalive:true", sep = ","), val.method !== "GET" && (options += sep + "method:" + quote(val.method, 0), sep = ","), val.mode !== "cors" && (options += sep + "mode:" + quote(val.mode, 0), sep = ","), val.redirect !== "follow" && (options += sep + "redirect:" + quote(val.redirect, 0), sep = ","), val.referrer !== "about:client" && (options += sep + "referrer:" + quote(val.referrer, 0), sep = ","), val.referrerPolicy && (options += sep + "referrerPolicy:" + quote(val.referrerPolicy, 0)), state.buf.push(bodySerialized ? options + "})" : options ? ",{" + options + "})" : ")"), !0;
826
+ let seenHeaders = state.refs.get(val.headers);
827
+ if (seenHeaders) options += sep + "headers:" + ensureId(state, seenHeaders), sep = ",";
828
+ else {
829
+ state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null));
830
+ let headers = stringEntriesToHeadersInit(val.headers);
831
+ headers && (options += sep + "headers:" + headers, sep = ",");
832
+ }
833
+ return val.integrity && (options += sep + "integrity:" + quote(val.integrity, 0), sep = ","), val.keepalive && (options += sep + "keepalive:true", sep = ","), val.method !== "GET" && (options += sep + "method:" + quote(val.method, 0), sep = ","), val.mode !== "cors" && (options += sep + "mode:" + quote(val.mode, 0), sep = ","), val.redirect !== "follow" && (options += sep + "redirect:" + quote(val.redirect, 0), sep = ","), val.referrer !== "about:client" && (options += sep + "referrer:" + quote(val.referrer, 0), sep = ","), val.referrerPolicy && (options += sep + "referrerPolicy:" + quote(val.referrerPolicy, 0)), state.buf.push(bodySerialized ? options + "})" : options ? ",{" + options + "})" : ")"), !0;
819
834
  }
820
835
  function writeResponse(state, val, ref) {
821
836
  let sep = "", options = "";
822
837
  val.status !== 200 && (options += "status:" + val.status, sep = ","), val.statusText && (options += sep + "statusText:" + quote(val.statusText, 0), sep = ",");
823
- let headers = stringEntriesToHeadersInit(val.headers);
824
- return state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null)), headers && (options += sep + "headers:" + headers), !val.body || val.bodyUsed ? state.buf.push("new Response" + (options ? "(null,{" + options + "})" : "")) : (state.buf.push("new Response("), state.buf.push((writeProp(state, val.body, ref, "body") ? "" : "null") + (options ? ",{" + options + "})" : ")"))), !0;
838
+ let seenHeaders = state.refs.get(val.headers);
839
+ if (seenHeaders) options += sep + "headers:" + ensureId(state, seenHeaders);
840
+ else {
841
+ state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null));
842
+ let headers = stringEntriesToHeadersInit(val.headers);
843
+ headers && (options += sep + "headers:" + headers);
844
+ }
845
+ return !val.body || val.bodyUsed ? state.buf.push("new Response" + (options ? "(null,{" + options + "})" : "")) : (state.buf.push("new Response("), state.buf.push((writeProp(state, val.body, ref, "body") ? "" : "null") + (options ? ",{" + options + "})" : ")"))), !0;
825
846
  }
826
847
  function writeReadableStream(state, val, ref) {
827
848
  let { boundary, channel } = state;
@@ -2054,7 +2075,7 @@ function writeTriggerScript(html, triggers) {
2054
2075
  default: return `(e=>e?.addEventListener("${trigger.type.slice(3)}",l,{once:1}))(document.querySelector(${JSON.stringify(trigger.selector)})||l())`;
2055
2076
  }
2056
2077
  });
2057
- writeScript(`((p,h,d,l=$=>d||p.after(new Range().createContextualFragment(d=h)))=>${exprs.length > 1 ? `{${exprs.join(";")}}` : exprs[0]})(document.currentScript,${htmlStr})`);
2078
+ writeScript(`((p,h,d,l=$=>{d||p.after(new Range().createContextualFragment(d=h))})=>${exprs.length > 1 ? `{${exprs.join(";")}}` : exprs[0]})(document.currentScript,${htmlStr})`);
2058
2079
  }
2059
2080
  function toObjectExpression(options) {
2060
2081
  let result = "{", sep = "";
@@ -253,7 +253,12 @@ function stringifyClassObject(name, value) {
253
253
  return value ? name : "";
254
254
  }
255
255
  function stringifyStyleObject(name, value) {
256
- return value || value === 0 ? name + ":" + value : "";
256
+ return value || value === 0 ? escapeStyleAttr(name) + ":" + escapeStyleAttr(value + "") : "";
257
+ }
258
+ const unsafeStyleAttrReg = /[\\;]/g;
259
+ const replaceUnsafeStyleAttr = (c) => c === ";" ? "\\3B " : "\\\\";
260
+ function escapeStyleAttr(str) {
261
+ return unsafeStyleAttrReg.test(str) ? str.replace(unsafeStyleAttrReg, replaceUnsafeStyleAttr) : str;
257
262
  }
258
263
  const toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
259
264
  let str = "";
@@ -2711,6 +2716,7 @@ function detectForSelector(bodySection, keyBinding) {
2711
2716
  }
2712
2717
  function onlyComparesKey(closure, canonical, bodySection, keyBinding) {
2713
2718
  let found = false;
2719
+ const keyReads = /* @__PURE__ */ new Map();
2714
2720
  for (let chain = closure; chain; chain = chain.upstreamAlias) for (const expr of chain.reads) {
2715
2721
  if (expr.section !== bodySection) continue;
2716
2722
  let other = false;
@@ -2718,13 +2724,23 @@ function onlyComparesKey(closure, canonical, bodySection, keyBinding) {
2718
2724
  const resolved = read.extra.read;
2719
2725
  const at = resolved && resolvesTo(resolved, canonical);
2720
2726
  if (!at) return;
2721
- if (at === 2 || resolved.getter || !readsKey(read.comparedTo?.extra?.read, keyBinding)) other = true;
2722
- else found = true;
2727
+ const keyRead = read.comparedTo?.extra?.read;
2728
+ if (at === 2 || resolved.getter || !readsKey(keyRead, keyBinding)) other = true;
2729
+ else {
2730
+ found = true;
2731
+ if (keyRead && !keyRead.props && getCanonicalBinding(keyRead.binding) === getCanonicalBinding(keyBinding)) keyReads.set(expr, bindingUtil.add(keyReads.get(expr), keyRead.binding));
2732
+ }
2723
2733
  });
2724
2734
  if (other) return false;
2725
2735
  }
2736
+ if (found) for (const [expr, dropped] of keyReads) dropKeyReferences(expr, dropped);
2726
2737
  return found;
2727
2738
  }
2739
+ function dropKeyReferences(expr, dropped) {
2740
+ if (dropReferencedBindings(expr, dropped)) forEach(dropped, (binding) => {
2741
+ binding.forcePersist = true;
2742
+ });
2743
+ }
2728
2744
  function resolvesTo(read, canonical) {
2729
2745
  let binding = read.binding;
2730
2746
  let through = 0;
@@ -6922,6 +6938,15 @@ function finalizeReferences() {
6922
6938
  readsByExpression.clear();
6923
6939
  fnReadsByExpression.clear();
6924
6940
  }
6941
+ function dropReferencedBindings(expr, drop) {
6942
+ let kept;
6943
+ forEach(expr.referencedBindings, (binding) => {
6944
+ if (!bindingUtil.has(drop, binding)) kept = bindingUtil.add(kept, binding);
6945
+ });
6946
+ if (Array.isArray(kept)) return false;
6947
+ expr.referencedBindings = kept;
6948
+ return true;
6949
+ }
6925
6950
  function getMaxOwnSourceOffset(intersection, section) {
6926
6951
  let scopeOffset;
6927
6952
  const trackScopeOffset = (source) => {
@@ -125,6 +125,7 @@ export declare function setReferencesScope(path: t.NodePath<any>): void;
125
125
  export declare function mergeReferences<T extends t.Node>(section: Section, target: T, nodes: (t.Node | undefined)[]): NonNullable<T["extra"]> & ReferencedExtra;
126
126
  export declare function compareReferences(a: ReferencedBindings, b: ReferencedBindings): number;
127
127
  export declare function finalizeReferences(): void;
128
+ export declare function dropReferencedBindings(expr: ReferencedExtra, drop: ReferencedBindings): boolean;
128
129
  export declare const intersectionMeta: WeakMap<Intersection, {
129
130
  id: number;
130
131
  scopeOffset: Binding | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.3.17",
3
+ "version": "6.3.19",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",
@@ -54,7 +54,7 @@
54
54
  "magic-string": "^0.30.21"
55
55
  },
56
56
  "devDependencies": {
57
- "@marko/runtime-tags": "npm:marko@6.3.17",
57
+ "@marko/runtime-tags": "npm:marko@6.3.19",
58
58
  "marko": "5.39.26"
59
59
  },
60
60
  "engines": {