marko 6.1.18 → 6.1.21

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
@@ -230,19 +230,12 @@ function push(opt, item) {
230
230
  }
231
231
  //#endregion
232
232
  //#region src/dom/event.ts
233
- const defaultDelegator = /* @__PURE__ */ createDelegator();
234
233
  function _on(element, type, handler) {
235
234
  assertHandlerIsFunction("on" + type[0].toUpperCase() + type.slice(1), handler);
236
- if (element["$" + type] === void 0) defaultDelegator(element, type, handleDelegated);
235
+ if (element["$" + type] === void 0) delegate(type, handleDelegated);
237
236
  element["$" + type] = handler || null;
238
237
  }
239
- /* @__NO_SIDE_EFFECTS__ */
240
- function createDelegator() {
241
- const kEvents = Symbol();
242
- return function ensureDelegated(node, type, handler) {
243
- ((node = node.getRootNode())[kEvents] ||= {})[type] ||= (node.addEventListener(type, handler, true), 1);
244
- };
245
- }
238
+ const delegate = (type, handler) => handler[type] ||= (document.addEventListener(type, handler, true), 1);
246
239
  function handleDelegated(ev) {
247
240
  let target = !rendering && ev.target;
248
241
  Object.defineProperty(ev, "currentTarget", {
@@ -725,8 +718,8 @@ function init(runtimeId = "M") {
725
718
  }
726
719
  };
727
720
  const serializeContext = ((data, registryId) => typeof data === "number" ? registryId ? registeredValues[registryId](getScope(data)) : getScope(data) : applyScopes(data));
728
- const createVisitBranches = (branchScopesStack = [], branchStarts = [], orphanBranches = [], curBranchScopes) => {
729
- return (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length) => {
721
+ const createVisitBranches = (branchScopesStack = [], branchStarts = [], orphanBranches = [], deferredOwners = [], curBranchScopes) => {
722
+ return (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length, j = deferredOwners.length) => {
730
723
  if (visitType !== "[") {
731
724
  visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit;
732
725
  accessor = "BranchScopes:" + lastToken;
@@ -753,6 +746,10 @@ function init(runtimeId = "M") {
753
746
  branch["#EndNode"] = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
754
747
  }
755
748
  while (i && orphanBranches[--i]["#Id"] > branchId) setParentBranch(orphanBranches.pop(), branch);
749
+ while (j && deferredOwners[--j]["#Id"] > branchId) {
750
+ const owner = deferredOwners.pop();
751
+ if (owner["#ClosestBranch"] !== owner) owner["#ClosestBranch"] = branch;
752
+ }
756
753
  nextToken();
757
754
  }
758
755
  if (endedBranches) {
@@ -765,7 +762,7 @@ function init(runtimeId = "M") {
765
762
  curBranchScopes = void 0;
766
763
  }
767
764
  branchStarts.push(visit);
768
- }
765
+ } else deferredOwners.push(visitScope);
769
766
  };
770
767
  };
771
768
  const nextToken = () => lastToken = visitText.slice(lastTokenIndex, (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1);
@@ -867,7 +864,6 @@ function _el(id, accessor) {
867
864
  //#endregion
868
865
  //#region src/dom/controllable.ts
869
866
  let inputType = "";
870
- const controllableDelegate = /* @__PURE__ */ createDelegator();
871
867
  function _attr_input_checked_default(scope, nodeAccessor, checked) {
872
868
  const el = scope[nodeAccessor];
873
869
  const normalizedChecked = isNotVoid(checked);
@@ -927,7 +923,7 @@ function _attr_input_checkedValue_script(scope, nodeAccessor) {
927
923
  const oldValue = scope["ControlledValue:" + nodeAccessor];
928
924
  const newValue = Array.isArray(oldValue) ? updateList(oldValue, el.value, el.checked) : el.checked ? el.value : void 0;
929
925
  if (el.name && el.type[0] === "r") {
930
- for (const radio of el.getRootNode().querySelectorAll(`[type=radio][name=${CSS.escape(el.name)}]`)) if (radio.form === el.form) radio.checked = Array.isArray(oldValue) ? oldValue.includes(radio.value) : oldValue === radio.value;
926
+ for (const radio of document.querySelectorAll(`[type=radio][name=${CSS.escape(el.name)}]`)) if (radio.form === el.form) radio.checked = Array.isArray(oldValue) ? oldValue.includes(radio.value) : oldValue === radio.value;
931
927
  } else el.checked = !el.checked;
932
928
  checkedValueChange(newValue);
933
929
  run();
@@ -969,7 +965,7 @@ function _attr_input_value_script(scope, nodeAccessor) {
969
965
  }
970
966
  function setInputValue(el, value) {
971
967
  if (el.value !== value) {
972
- const updatedPosition = resolveCursorPosition(inputType, el.getRootNode().activeElement === el && el.selectionStart, el.value, el.value = value);
968
+ const updatedPosition = resolveCursorPosition(inputType, document.activeElement === el && el.selectionStart, el.value, el.value = value);
973
969
  if (~updatedPosition) el.setSelectionRange(updatedPosition, updatedPosition);
974
970
  }
975
971
  }
@@ -1076,8 +1072,8 @@ function _attr_details_or_dialog_open_script(scope, nodeAccessor) {
1076
1072
  }
1077
1073
  function syncControllableFormInput(el, hasChanged, onChange) {
1078
1074
  el._ = onChange;
1079
- controllableDelegate(el, "input", handleChange);
1080
- if (el.form) controllableDelegate(el.form, "reset", handleFormReset);
1075
+ delegate("input", handleChange);
1076
+ if (el.form) delegate("reset", handleFormReset);
1081
1077
  if (isResuming && hasChanged(el)) queueMicrotask(onChange);
1082
1078
  }
1083
1079
  function handleChange(ev) {
@@ -1198,11 +1194,16 @@ function attrsInternal(scope, nodeAccessor, nextAttrs) {
1198
1194
  scope["ControlledHandler:" + nodeAccessor] = 0;
1199
1195
  switch (el.tagName) {
1200
1196
  case "INPUT":
1201
- if ("checked" in nextAttrs || "checkedChange" in nextAttrs) _attr_input_checked(scope, nodeAccessor, nextAttrs.checked, nextAttrs.checkedChange);
1202
- else if ("checkedValue" in nextAttrs || "checkedValueChange" in nextAttrs) _attr_input_checkedValue(scope, nodeAccessor, nextAttrs.checkedValue, nextAttrs.checkedValueChange, nextAttrs.value);
1203
- else if ("value" in nextAttrs || "valueChange" in nextAttrs) _attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange);
1204
- else break;
1205
- skip = /^(?:value|checked(?:Value)?)(?:Change)?$/;
1197
+ if ("checked" in nextAttrs || "checkedChange" in nextAttrs) {
1198
+ _attr_input_checked(scope, nodeAccessor, nextAttrs.checked, nextAttrs.checkedChange);
1199
+ skip = /^checked(?:Value)?(?:Change)?$/;
1200
+ } else if ("checkedValue" in nextAttrs || "checkedValueChange" in nextAttrs) {
1201
+ _attr_input_checkedValue(scope, nodeAccessor, nextAttrs.checkedValue, nextAttrs.checkedValueChange, nextAttrs.value);
1202
+ skip = /^(?:value|checked(?:Value)?)(?:Change)?$/;
1203
+ } else if ("value" in nextAttrs || "valueChange" in nextAttrs) {
1204
+ _attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange);
1205
+ skip = /^value(?:Change)?$/;
1206
+ } else break;
1206
1207
  break;
1207
1208
  case "SELECT":
1208
1209
  if ("value" in nextAttrs || "valueChange" in nextAttrs) {
@@ -1353,7 +1354,12 @@ function _await_promise(nodeAccessor, params) {
1353
1354
  c() {
1354
1355
  if (--awaitCounter.i) return 1;
1355
1356
  if (tryBranch === scope[branchAccessor]) {
1356
- if (scope[nodeAccessor].parentNode) scope[nodeAccessor].replaceWith(scope[branchAccessor]["#StartNode"].parentNode);
1357
+ const anchor = scope[nodeAccessor];
1358
+ if (anchor.parentNode) {
1359
+ const detachedParent = scope[branchAccessor]["#StartNode"].parentNode;
1360
+ if (detachedParent === anchor.parentNode) anchor.remove();
1361
+ else anchor.replaceWith(detachedParent);
1362
+ }
1357
1363
  } else dismissPlaceholder(tryBranch);
1358
1364
  queueEffect(tryBranch, runPendingEffects);
1359
1365
  }
@@ -1933,7 +1939,7 @@ const compat = {
1933
1939
  component.scope = branch;
1934
1940
  classIdToBranch.delete(component.id);
1935
1941
  }
1936
- if (typeof args[0] === "object" && "renderBody" in args[0]) {
1942
+ if (args[0] && typeof args[0] === "object" && "renderBody" in args[0]) {
1937
1943
  const input = args[0];
1938
1944
  const normalizedInput = args[0] = {};
1939
1945
  for (const key in input) normalizedInput[key === "renderBody" ? "content" : key] = input[key];
@@ -2052,35 +2058,34 @@ function _load_setup(nodeAccessor, childScopeAccessor, load) {
2052
2058
  };
2053
2059
  }
2054
2060
  function insertLoaded(renderer, branch, marker, awaitCounter) {
2055
- const parent = marker.parentNode;
2056
- syncGen(branch);
2057
- renderer["clone"](branch, parent.namespaceURI);
2058
- setupBranch(renderer, branch);
2059
- applyLoad(branch, () => {
2061
+ const parent = marker.parentNode, values = branch["#Load"], insert = () => {
2060
2062
  insertBranchBefore(branch, parent, marker);
2061
2063
  marker.remove();
2062
2064
  awaitCounter?.c();
2063
- });
2064
- }
2065
- function loadFailed(scope, awaitCounter) {
2066
- return (error) => {
2067
- if (awaitCounter) awaitCounter.i = 0;
2068
- queueAsyncRender(scope, renderCatch, error);
2069
2065
  };
2070
- }
2071
- function applyLoad(scope, insert) {
2072
- const values = scope["#Load"];
2073
2066
  let remaining;
2074
- scope["#Load"] = 0;
2067
+ syncGen(branch);
2068
+ renderer["clone"](branch, parent.namespaceURI);
2069
+ branch["#Load"] = 0;
2075
2070
  if (remaining = values?.size) for (const [promise, entry] of values) promise.then((signal) => {
2076
2071
  entry["signal"] = signal;
2077
- if (!--remaining) queueAsyncRender(scope, (scope) => {
2078
- syncGen(scope);
2079
- values.forEach((e) => e["signal"]._(scope, e["value"]));
2072
+ if (!--remaining) queueAsyncRender(branch, (branch) => {
2073
+ syncGen(branch);
2074
+ renderer["setup"]?.(branch);
2075
+ values.forEach((e) => e["signal"]._(branch, e["value"]));
2080
2076
  insert();
2081
2077
  });
2082
2078
  }, () => 0);
2083
- else insert();
2079
+ else {
2080
+ setupBranch(renderer, branch);
2081
+ insert();
2082
+ }
2083
+ }
2084
+ function loadFailed(scope, awaitCounter) {
2085
+ return (error) => {
2086
+ if (awaitCounter) awaitCounter.i = 0;
2087
+ queueAsyncRender(scope, renderCatch, error);
2088
+ };
2084
2089
  }
2085
2090
  function _load_signal(load) {
2086
2091
  let pending;
@@ -228,19 +228,12 @@ function push(opt, item) {
228
228
  }
229
229
  //#endregion
230
230
  //#region src/dom/event.ts
231
- const defaultDelegator = /* @__PURE__ */ createDelegator();
232
231
  function _on(element, type, handler) {
233
232
  assertHandlerIsFunction("on" + type[0].toUpperCase() + type.slice(1), handler);
234
- if (element["$" + type] === void 0) defaultDelegator(element, type, handleDelegated);
233
+ if (element["$" + type] === void 0) delegate(type, handleDelegated);
235
234
  element["$" + type] = handler || null;
236
235
  }
237
- /* @__NO_SIDE_EFFECTS__ */
238
- function createDelegator() {
239
- const kEvents = Symbol();
240
- return function ensureDelegated(node, type, handler) {
241
- ((node = node.getRootNode())[kEvents] ||= {})[type] ||= (node.addEventListener(type, handler, true), 1);
242
- };
243
- }
236
+ const delegate = (type, handler) => handler[type] ||= (document.addEventListener(type, handler, true), 1);
244
237
  function handleDelegated(ev) {
245
238
  let target = !rendering && ev.target;
246
239
  Object.defineProperty(ev, "currentTarget", {
@@ -723,8 +716,8 @@ function init(runtimeId = "M") {
723
716
  }
724
717
  };
725
718
  const serializeContext = ((data, registryId) => typeof data === "number" ? registryId ? registeredValues[registryId](getScope(data)) : getScope(data) : applyScopes(data));
726
- const createVisitBranches = (branchScopesStack = [], branchStarts = [], orphanBranches = [], curBranchScopes) => {
727
- return (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length) => {
719
+ const createVisitBranches = (branchScopesStack = [], branchStarts = [], orphanBranches = [], deferredOwners = [], curBranchScopes) => {
720
+ return (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length, j = deferredOwners.length) => {
728
721
  if (visitType !== "[") {
729
722
  visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit;
730
723
  accessor = "BranchScopes:" + lastToken;
@@ -751,6 +744,10 @@ function init(runtimeId = "M") {
751
744
  branch["#EndNode"] = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
752
745
  }
753
746
  while (i && orphanBranches[--i]["#Id"] > branchId) setParentBranch(orphanBranches.pop(), branch);
747
+ while (j && deferredOwners[--j]["#Id"] > branchId) {
748
+ const owner = deferredOwners.pop();
749
+ if (owner["#ClosestBranch"] !== owner) owner["#ClosestBranch"] = branch;
750
+ }
754
751
  nextToken();
755
752
  }
756
753
  if (endedBranches) {
@@ -763,7 +760,7 @@ function init(runtimeId = "M") {
763
760
  curBranchScopes = void 0;
764
761
  }
765
762
  branchStarts.push(visit);
766
- }
763
+ } else deferredOwners.push(visitScope);
767
764
  };
768
765
  };
769
766
  const nextToken = () => lastToken = visitText.slice(lastTokenIndex, (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1);
@@ -865,7 +862,6 @@ function _el(id, accessor) {
865
862
  //#endregion
866
863
  //#region src/dom/controllable.ts
867
864
  let inputType = "";
868
- const controllableDelegate = /* @__PURE__ */ createDelegator();
869
865
  function _attr_input_checked_default(scope, nodeAccessor, checked) {
870
866
  const el = scope[nodeAccessor];
871
867
  const normalizedChecked = isNotVoid(checked);
@@ -925,7 +921,7 @@ function _attr_input_checkedValue_script(scope, nodeAccessor) {
925
921
  const oldValue = scope["ControlledValue:" + nodeAccessor];
926
922
  const newValue = Array.isArray(oldValue) ? updateList(oldValue, el.value, el.checked) : el.checked ? el.value : void 0;
927
923
  if (el.name && el.type[0] === "r") {
928
- for (const radio of el.getRootNode().querySelectorAll(`[type=radio][name=${CSS.escape(el.name)}]`)) if (radio.form === el.form) radio.checked = Array.isArray(oldValue) ? oldValue.includes(radio.value) : oldValue === radio.value;
924
+ for (const radio of document.querySelectorAll(`[type=radio][name=${CSS.escape(el.name)}]`)) if (radio.form === el.form) radio.checked = Array.isArray(oldValue) ? oldValue.includes(radio.value) : oldValue === radio.value;
929
925
  } else el.checked = !el.checked;
930
926
  checkedValueChange(newValue);
931
927
  run();
@@ -967,7 +963,7 @@ function _attr_input_value_script(scope, nodeAccessor) {
967
963
  }
968
964
  function setInputValue(el, value) {
969
965
  if (el.value !== value) {
970
- const updatedPosition = resolveCursorPosition(inputType, el.getRootNode().activeElement === el && el.selectionStart, el.value, el.value = value);
966
+ const updatedPosition = resolveCursorPosition(inputType, document.activeElement === el && el.selectionStart, el.value, el.value = value);
971
967
  if (~updatedPosition) el.setSelectionRange(updatedPosition, updatedPosition);
972
968
  }
973
969
  }
@@ -1074,8 +1070,8 @@ function _attr_details_or_dialog_open_script(scope, nodeAccessor) {
1074
1070
  }
1075
1071
  function syncControllableFormInput(el, hasChanged, onChange) {
1076
1072
  el._ = onChange;
1077
- controllableDelegate(el, "input", handleChange);
1078
- if (el.form) controllableDelegate(el.form, "reset", handleFormReset);
1073
+ delegate("input", handleChange);
1074
+ if (el.form) delegate("reset", handleFormReset);
1079
1075
  if (isResuming && hasChanged(el)) queueMicrotask(onChange);
1080
1076
  }
1081
1077
  function handleChange(ev) {
@@ -1196,11 +1192,16 @@ function attrsInternal(scope, nodeAccessor, nextAttrs) {
1196
1192
  scope["ControlledHandler:" + nodeAccessor] = 0;
1197
1193
  switch (el.tagName) {
1198
1194
  case "INPUT":
1199
- if ("checked" in nextAttrs || "checkedChange" in nextAttrs) _attr_input_checked(scope, nodeAccessor, nextAttrs.checked, nextAttrs.checkedChange);
1200
- else if ("checkedValue" in nextAttrs || "checkedValueChange" in nextAttrs) _attr_input_checkedValue(scope, nodeAccessor, nextAttrs.checkedValue, nextAttrs.checkedValueChange, nextAttrs.value);
1201
- else if ("value" in nextAttrs || "valueChange" in nextAttrs) _attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange);
1202
- else break;
1203
- skip = /^(?:value|checked(?:Value)?)(?:Change)?$/;
1195
+ if ("checked" in nextAttrs || "checkedChange" in nextAttrs) {
1196
+ _attr_input_checked(scope, nodeAccessor, nextAttrs.checked, nextAttrs.checkedChange);
1197
+ skip = /^checked(?:Value)?(?:Change)?$/;
1198
+ } else if ("checkedValue" in nextAttrs || "checkedValueChange" in nextAttrs) {
1199
+ _attr_input_checkedValue(scope, nodeAccessor, nextAttrs.checkedValue, nextAttrs.checkedValueChange, nextAttrs.value);
1200
+ skip = /^(?:value|checked(?:Value)?)(?:Change)?$/;
1201
+ } else if ("value" in nextAttrs || "valueChange" in nextAttrs) {
1202
+ _attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange);
1203
+ skip = /^value(?:Change)?$/;
1204
+ } else break;
1204
1205
  break;
1205
1206
  case "SELECT":
1206
1207
  if ("value" in nextAttrs || "valueChange" in nextAttrs) {
@@ -1351,7 +1352,12 @@ function _await_promise(nodeAccessor, params) {
1351
1352
  c() {
1352
1353
  if (--awaitCounter.i) return 1;
1353
1354
  if (tryBranch === scope[branchAccessor]) {
1354
- if (scope[nodeAccessor].parentNode) scope[nodeAccessor].replaceWith(scope[branchAccessor]["#StartNode"].parentNode);
1355
+ const anchor = scope[nodeAccessor];
1356
+ if (anchor.parentNode) {
1357
+ const detachedParent = scope[branchAccessor]["#StartNode"].parentNode;
1358
+ if (detachedParent === anchor.parentNode) anchor.remove();
1359
+ else anchor.replaceWith(detachedParent);
1360
+ }
1355
1361
  } else dismissPlaceholder(tryBranch);
1356
1362
  queueEffect(tryBranch, runPendingEffects);
1357
1363
  }
@@ -1931,7 +1937,7 @@ const compat = {
1931
1937
  component.scope = branch;
1932
1938
  classIdToBranch.delete(component.id);
1933
1939
  }
1934
- if (typeof args[0] === "object" && "renderBody" in args[0]) {
1940
+ if (args[0] && typeof args[0] === "object" && "renderBody" in args[0]) {
1935
1941
  const input = args[0];
1936
1942
  const normalizedInput = args[0] = {};
1937
1943
  for (const key in input) normalizedInput[key === "renderBody" ? "content" : key] = input[key];
@@ -2050,35 +2056,34 @@ function _load_setup(nodeAccessor, childScopeAccessor, load) {
2050
2056
  };
2051
2057
  }
2052
2058
  function insertLoaded(renderer, branch, marker, awaitCounter) {
2053
- const parent = marker.parentNode;
2054
- syncGen(branch);
2055
- renderer["clone"](branch, parent.namespaceURI);
2056
- setupBranch(renderer, branch);
2057
- applyLoad(branch, () => {
2059
+ const parent = marker.parentNode, values = branch["#Load"], insert = () => {
2058
2060
  insertBranchBefore(branch, parent, marker);
2059
2061
  marker.remove();
2060
2062
  awaitCounter?.c();
2061
- });
2062
- }
2063
- function loadFailed(scope, awaitCounter) {
2064
- return (error) => {
2065
- if (awaitCounter) awaitCounter.i = 0;
2066
- queueAsyncRender(scope, renderCatch, error);
2067
2063
  };
2068
- }
2069
- function applyLoad(scope, insert) {
2070
- const values = scope["#Load"];
2071
2064
  let remaining;
2072
- scope["#Load"] = 0;
2065
+ syncGen(branch);
2066
+ renderer["clone"](branch, parent.namespaceURI);
2067
+ branch["#Load"] = 0;
2073
2068
  if (remaining = values?.size) for (const [promise, entry] of values) promise.then((signal) => {
2074
2069
  entry["signal"] = signal;
2075
- if (!--remaining) queueAsyncRender(scope, (scope) => {
2076
- syncGen(scope);
2077
- values.forEach((e) => e["signal"]._(scope, e["value"]));
2070
+ if (!--remaining) queueAsyncRender(branch, (branch) => {
2071
+ syncGen(branch);
2072
+ renderer["setup"]?.(branch);
2073
+ values.forEach((e) => e["signal"]._(branch, e["value"]));
2078
2074
  insert();
2079
2075
  });
2080
2076
  }, () => 0);
2081
- else insert();
2077
+ else {
2078
+ setupBranch(renderer, branch);
2079
+ insert();
2080
+ }
2081
+ }
2082
+ function loadFailed(scope, awaitCounter) {
2083
+ return (error) => {
2084
+ if (awaitCounter) awaitCounter.i = 0;
2085
+ queueAsyncRender(scope, renderCatch, error);
2086
+ };
2082
2087
  }
2083
2088
  function _load_signal(load) {
2084
2089
  let pending;
@@ -877,8 +877,11 @@ function writeDate(state, val) {
877
877
  state.buf.push("new Date(" + +val + ")");
878
878
  return true;
879
879
  }
880
+ const unsafeRegExpSourceReg = /\\[\s\S]|</g;
881
+ const replaceUnsafeRegExpSourceChar = (match) => match === "<" || match === "\\<" ? "\\x3C" : match;
880
882
  function writeRegExp(state, val) {
881
- state.buf.push(val + "");
883
+ const { source } = val;
884
+ state.buf.push("/" + (source.includes("<") ? source.replace(unsafeRegExpSourceReg, replaceUnsafeRegExpSourceChar) : source) + "/" + val.flags);
882
885
  return true;
883
886
  }
884
887
  function writePromise(state, val, ref) {
@@ -1008,7 +1011,7 @@ function writeWeakMap(state) {
1008
1011
  }
1009
1012
  function writeError(state, val, ref) {
1010
1013
  const result = "new " + val.constructor.name + "(" + quote(val.message + "", 0);
1011
- if (val.cause) {
1014
+ if (val.cause !== void 0) {
1012
1015
  state.buf.push(result + ",{cause:");
1013
1016
  writeProp(state, val.cause, ref, "cause");
1014
1017
  state.buf.push("})");
@@ -2464,7 +2467,8 @@ function _attr_style(value) {
2464
2467
  }
2465
2468
  function _attr_option_value(value) {
2466
2469
  const valueAttr = _attr("value", value);
2467
- if (normalizedValueMatches(getContext(kSelectedValue), value)) {
2470
+ const selectedValue = getContext(kSelectedValue);
2471
+ if (selectedValue !== void 0 && normalizedValueMatches(selectedValue, value)) {
2468
2472
  {
2469
2473
  const matched = getContext(kSelectedValueMatched);
2470
2474
  if (matched) matched.value = true;
@@ -2475,29 +2479,29 @@ function _attr_option_value(value) {
2475
2479
  }
2476
2480
  const kSelectedValue = Symbol("selectedValue");
2477
2481
  const kSelectedValueMatched = Symbol("selectedValueMatched");
2478
- function _attr_select_value(scopeId, nodeAccessor, value, valueChange, content) {
2479
- if (valueChange) writeControlledScope(3, scopeId, nodeAccessor, void 0, valueChange);
2482
+ function _attr_select_value(scopeId, nodeAccessor, value, valueChange, content, serializeType) {
2483
+ if (valueChange) writeControlledScope(3, scopeId, nodeAccessor, void 0, valueChange, serializeType);
2480
2484
  if (content) if (valueChange) {
2481
2485
  const matched = { value: false };
2482
2486
  withContext(kSelectedValue, value, () => withContext(kSelectedValueMatched, matched, content));
2483
2487
  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);
2484
2488
  } else withContext(kSelectedValue, value, content);
2485
2489
  }
2486
- function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange) {
2487
- if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange);
2490
+ function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
2491
+ if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType);
2488
2492
  return _escape(value);
2489
2493
  }
2490
- function _attr_input_value(scopeId, nodeAccessor, value, valueChange) {
2491
- if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange);
2494
+ function _attr_input_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
2495
+ if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType);
2492
2496
  return _attr("value", value);
2493
2497
  }
2494
- function _attr_input_checked(scopeId, nodeAccessor, checked, checkedChange) {
2495
- if (checkedChange) writeControlledScope(0, scopeId, nodeAccessor, void 0, checkedChange);
2498
+ function _attr_input_checked(scopeId, nodeAccessor, checked, checkedChange, serializeType) {
2499
+ if (checkedChange) writeControlledScope(0, scopeId, nodeAccessor, void 0, checkedChange, serializeType);
2496
2500
  return isNotVoid(checked) ? " checked" : "";
2497
2501
  }
2498
- function _attr_input_checkedValue(scopeId, nodeAccessor, checkedValue, checkedValueChange, value) {
2502
+ function _attr_input_checkedValue(scopeId, nodeAccessor, checkedValue, checkedValueChange, value, serializeType) {
2499
2503
  const valueAttr = _attr("value", value);
2500
- if (checkedValueChange) writeControlledScope(1, scopeId, nodeAccessor, getCheckedValueRef(checkedValue), checkedValueChange);
2504
+ if (checkedValueChange) writeControlledScope(1, scopeId, nodeAccessor, getCheckedValueRef(checkedValue), checkedValueChange, serializeType);
2501
2505
  return normalizedValueMatches(checkedValue, value) ? valueAttr + " checked" : valueAttr;
2502
2506
  }
2503
2507
  const checkedValuesRefs = /* @__PURE__ */ new WeakMap();
@@ -2511,9 +2515,9 @@ function getCheckedValueRef(checkedValue) {
2511
2515
  return ref;
2512
2516
  }
2513
2517
  }
2514
- function _attr_details_or_dialog_open(scopeId, nodeAccessor, open, openChange) {
2518
+ function _attr_details_or_dialog_open(scopeId, nodeAccessor, open, openChange, serializeType) {
2515
2519
  const normalizedOpen = isNotVoid(open);
2516
- if (openChange) writeControlledScope(4, scopeId, nodeAccessor, normalizedOpen || void 0, openChange);
2520
+ if (openChange) writeControlledScope(4, scopeId, nodeAccessor, normalizedOpen || void 0, openChange, serializeType);
2517
2521
  return normalizedOpen ? " open" : "";
2518
2522
  }
2519
2523
  function _attr_nonce() {
@@ -2529,11 +2533,16 @@ function _attrs(data, nodeAccessor, scopeId, tagName) {
2529
2533
  switch (tagName) {
2530
2534
  case "input":
2531
2535
  assertExclusiveAttrs(data);
2532
- if (data.checkedChange) result += _attr_input_checked(scopeId, nodeAccessor, data.checked, data.checkedChange);
2533
- else if ("checkedValue" in data || data.checkedValueChange) result += _attr_input_checkedValue(scopeId, nodeAccessor, data.checkedValue, data.checkedValueChange, data.value);
2534
- else if (data.valueChange) result += _attr_input_value(scopeId, nodeAccessor, data.value, data.valueChange);
2535
- else break;
2536
- skip = /^(?:value|checked(?:Value)?)(?:Change)?$|[\s/>"'=]/;
2536
+ if (data.checkedChange) {
2537
+ result += _attr_input_checked(scopeId, nodeAccessor, data.checked, data.checkedChange, 1);
2538
+ skip = /^checked(?:Value)?(?:Change)?$|[\s/>"'=]/;
2539
+ } else if ("checkedValue" in data || data.checkedValueChange) {
2540
+ result += _attr_input_checkedValue(scopeId, nodeAccessor, data.checkedValue, data.checkedValueChange, data.value, 1);
2541
+ skip = /^(?:value|checked(?:Value)?)(?:Change)?$|[\s/>"'=]/;
2542
+ } else if (data.valueChange) {
2543
+ result += _attr_input_value(scopeId, nodeAccessor, data.value, data.valueChange, 1);
2544
+ skip = /^value(?:Change)?$|[\s/>"'=]/;
2545
+ } else break;
2537
2546
  break;
2538
2547
  case "select":
2539
2548
  case "textarea":
@@ -2548,7 +2557,7 @@ function _attrs(data, nodeAccessor, scopeId, tagName) {
2548
2557
  case "details":
2549
2558
  case "dialog":
2550
2559
  if (data.openChange) {
2551
- result += _attr_details_or_dialog_open(scopeId, nodeAccessor, data.open, data.openChange);
2560
+ result += _attr_details_or_dialog_open(scopeId, nodeAccessor, data.open, data.openChange, 1);
2552
2561
  skip = /^open(?:Change)?$|[\s/>"'=]/;
2553
2562
  }
2554
2563
  break;
@@ -2594,12 +2603,15 @@ function _attrs_partial_content(data, skip, nodeAccessor, scopeId, tagName, seri
2594
2603
  _html(`${_attrs_partial(data, skip, nodeAccessor, scopeId, tagName)}>`);
2595
2604
  _attr_content(nodeAccessor, scopeId, data?.content, serializeReason);
2596
2605
  }
2597
- function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange) {
2606
+ function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange, serializeType) {
2598
2607
  assertHandlerIsFunction("valueChange", valueChange);
2599
- writeScope(scopeId, {
2608
+ writeScope(scopeId, serializeType ? {
2600
2609
  ["ControlledType:" + nodeAccessor]: type,
2601
2610
  ["ControlledValue:" + nodeAccessor]: value,
2602
2611
  ["ControlledHandler:" + nodeAccessor]: valueChange
2612
+ } : {
2613
+ ["ControlledValue:" + nodeAccessor]: value,
2614
+ ["ControlledHandler:" + nodeAccessor]: valueChange
2603
2615
  });
2604
2616
  }
2605
2617
  function stringAttr(name, value) {
@@ -2665,10 +2677,10 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
2665
2677
  const renderContent = content || normalizeDynamicRenderer(input.content);
2666
2678
  if (renderer === "textarea") {
2667
2679
  if (renderContent) throw new Error("A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead.");
2668
- _html(_attr_textarea_value(branchId, `#${renderer}/0`, input.value, input.valueChange));
2680
+ _html(_attr_textarea_value(branchId, `#${renderer}/0`, input.value, input.valueChange, 1));
2669
2681
  } else if (renderContent) {
2670
2682
  if (typeof renderContent !== "function") throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
2671
- if (renderer === "select" && ("value" in input || "valueChange" in input)) _attr_select_value(branchId, `#${renderer}/0`, input.value, input.valueChange, renderContent);
2683
+ if (renderer === "select" && ("value" in input || "valueChange" in input)) _attr_select_value(branchId, `#${renderer}/0`, input.value, input.valueChange, renderContent, 1);
2672
2684
  else _dynamic_tag(branchId, `#${renderer}/0`, renderContent, void 0, 0, void 0, serializeReason);
2673
2685
  }
2674
2686
  _html(`</${renderer}>`);