@marko/runtime-tags 6.1.19 → 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
@@ -718,8 +718,8 @@ function init(runtimeId = "M") {
718
718
  }
719
719
  };
720
720
  const serializeContext = ((data, registryId) => typeof data === "number" ? registryId ? registeredValues[registryId](getScope(data)) : getScope(data) : applyScopes(data));
721
- const createVisitBranches = (branchScopesStack = [], branchStarts = [], orphanBranches = [], curBranchScopes) => {
722
- 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) => {
723
723
  if (visitType !== "[") {
724
724
  visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit;
725
725
  accessor = "BranchScopes:" + lastToken;
@@ -746,6 +746,10 @@ function init(runtimeId = "M") {
746
746
  branch["#EndNode"] = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
747
747
  }
748
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
+ }
749
753
  nextToken();
750
754
  }
751
755
  if (endedBranches) {
@@ -758,7 +762,7 @@ function init(runtimeId = "M") {
758
762
  curBranchScopes = void 0;
759
763
  }
760
764
  branchStarts.push(visit);
761
- }
765
+ } else deferredOwners.push(visitScope);
762
766
  };
763
767
  };
764
768
  const nextToken = () => lastToken = visitText.slice(lastTokenIndex, (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1);
@@ -1190,11 +1194,16 @@ function attrsInternal(scope, nodeAccessor, nextAttrs) {
1190
1194
  scope["ControlledHandler:" + nodeAccessor] = 0;
1191
1195
  switch (el.tagName) {
1192
1196
  case "INPUT":
1193
- if ("checked" in nextAttrs || "checkedChange" in nextAttrs) _attr_input_checked(scope, nodeAccessor, nextAttrs.checked, nextAttrs.checkedChange);
1194
- else if ("checkedValue" in nextAttrs || "checkedValueChange" in nextAttrs) _attr_input_checkedValue(scope, nodeAccessor, nextAttrs.checkedValue, nextAttrs.checkedValueChange, nextAttrs.value);
1195
- else if ("value" in nextAttrs || "valueChange" in nextAttrs) _attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange);
1196
- else break;
1197
- 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;
1198
1207
  break;
1199
1208
  case "SELECT":
1200
1209
  if ("value" in nextAttrs || "valueChange" in nextAttrs) {
@@ -1345,7 +1354,12 @@ function _await_promise(nodeAccessor, params) {
1345
1354
  c() {
1346
1355
  if (--awaitCounter.i) return 1;
1347
1356
  if (tryBranch === scope[branchAccessor]) {
1348
- 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
+ }
1349
1363
  } else dismissPlaceholder(tryBranch);
1350
1364
  queueEffect(tryBranch, runPendingEffects);
1351
1365
  }
@@ -1925,7 +1939,7 @@ const compat = {
1925
1939
  component.scope = branch;
1926
1940
  classIdToBranch.delete(component.id);
1927
1941
  }
1928
- if (typeof args[0] === "object" && "renderBody" in args[0]) {
1942
+ if (args[0] && typeof args[0] === "object" && "renderBody" in args[0]) {
1929
1943
  const input = args[0];
1930
1944
  const normalizedInput = args[0] = {};
1931
1945
  for (const key in input) normalizedInput[key === "renderBody" ? "content" : key] = input[key];
@@ -2044,35 +2058,34 @@ function _load_setup(nodeAccessor, childScopeAccessor, load) {
2044
2058
  };
2045
2059
  }
2046
2060
  function insertLoaded(renderer, branch, marker, awaitCounter) {
2047
- const parent = marker.parentNode;
2048
- syncGen(branch);
2049
- renderer["clone"](branch, parent.namespaceURI);
2050
- setupBranch(renderer, branch);
2051
- applyLoad(branch, () => {
2061
+ const parent = marker.parentNode, values = branch["#Load"], insert = () => {
2052
2062
  insertBranchBefore(branch, parent, marker);
2053
2063
  marker.remove();
2054
2064
  awaitCounter?.c();
2055
- });
2056
- }
2057
- function loadFailed(scope, awaitCounter) {
2058
- return (error) => {
2059
- if (awaitCounter) awaitCounter.i = 0;
2060
- queueAsyncRender(scope, renderCatch, error);
2061
2065
  };
2062
- }
2063
- function applyLoad(scope, insert) {
2064
- const values = scope["#Load"];
2065
2066
  let remaining;
2066
- scope["#Load"] = 0;
2067
+ syncGen(branch);
2068
+ renderer["clone"](branch, parent.namespaceURI);
2069
+ branch["#Load"] = 0;
2067
2070
  if (remaining = values?.size) for (const [promise, entry] of values) promise.then((signal) => {
2068
2071
  entry["signal"] = signal;
2069
- if (!--remaining) queueAsyncRender(scope, (scope) => {
2070
- syncGen(scope);
2071
- 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"]));
2072
2076
  insert();
2073
2077
  });
2074
2078
  }, () => 0);
2075
- 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
+ };
2076
2089
  }
2077
2090
  function _load_signal(load) {
2078
2091
  let pending;
@@ -716,8 +716,8 @@ function init(runtimeId = "M") {
716
716
  }
717
717
  };
718
718
  const serializeContext = ((data, registryId) => typeof data === "number" ? registryId ? registeredValues[registryId](getScope(data)) : getScope(data) : applyScopes(data));
719
- const createVisitBranches = (branchScopesStack = [], branchStarts = [], orphanBranches = [], curBranchScopes) => {
720
- 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) => {
721
721
  if (visitType !== "[") {
722
722
  visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit;
723
723
  accessor = "BranchScopes:" + lastToken;
@@ -744,6 +744,10 @@ function init(runtimeId = "M") {
744
744
  branch["#EndNode"] = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
745
745
  }
746
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
+ }
747
751
  nextToken();
748
752
  }
749
753
  if (endedBranches) {
@@ -756,7 +760,7 @@ function init(runtimeId = "M") {
756
760
  curBranchScopes = void 0;
757
761
  }
758
762
  branchStarts.push(visit);
759
- }
763
+ } else deferredOwners.push(visitScope);
760
764
  };
761
765
  };
762
766
  const nextToken = () => lastToken = visitText.slice(lastTokenIndex, (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1);
@@ -1188,11 +1192,16 @@ function attrsInternal(scope, nodeAccessor, nextAttrs) {
1188
1192
  scope["ControlledHandler:" + nodeAccessor] = 0;
1189
1193
  switch (el.tagName) {
1190
1194
  case "INPUT":
1191
- if ("checked" in nextAttrs || "checkedChange" in nextAttrs) _attr_input_checked(scope, nodeAccessor, nextAttrs.checked, nextAttrs.checkedChange);
1192
- else if ("checkedValue" in nextAttrs || "checkedValueChange" in nextAttrs) _attr_input_checkedValue(scope, nodeAccessor, nextAttrs.checkedValue, nextAttrs.checkedValueChange, nextAttrs.value);
1193
- else if ("value" in nextAttrs || "valueChange" in nextAttrs) _attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange);
1194
- else break;
1195
- 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;
1196
1205
  break;
1197
1206
  case "SELECT":
1198
1207
  if ("value" in nextAttrs || "valueChange" in nextAttrs) {
@@ -1343,7 +1352,12 @@ function _await_promise(nodeAccessor, params) {
1343
1352
  c() {
1344
1353
  if (--awaitCounter.i) return 1;
1345
1354
  if (tryBranch === scope[branchAccessor]) {
1346
- 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
+ }
1347
1361
  } else dismissPlaceholder(tryBranch);
1348
1362
  queueEffect(tryBranch, runPendingEffects);
1349
1363
  }
@@ -1923,7 +1937,7 @@ const compat = {
1923
1937
  component.scope = branch;
1924
1938
  classIdToBranch.delete(component.id);
1925
1939
  }
1926
- if (typeof args[0] === "object" && "renderBody" in args[0]) {
1940
+ if (args[0] && typeof args[0] === "object" && "renderBody" in args[0]) {
1927
1941
  const input = args[0];
1928
1942
  const normalizedInput = args[0] = {};
1929
1943
  for (const key in input) normalizedInput[key === "renderBody" ? "content" : key] = input[key];
@@ -2042,35 +2056,34 @@ function _load_setup(nodeAccessor, childScopeAccessor, load) {
2042
2056
  };
2043
2057
  }
2044
2058
  function insertLoaded(renderer, branch, marker, awaitCounter) {
2045
- const parent = marker.parentNode;
2046
- syncGen(branch);
2047
- renderer["clone"](branch, parent.namespaceURI);
2048
- setupBranch(renderer, branch);
2049
- applyLoad(branch, () => {
2059
+ const parent = marker.parentNode, values = branch["#Load"], insert = () => {
2050
2060
  insertBranchBefore(branch, parent, marker);
2051
2061
  marker.remove();
2052
2062
  awaitCounter?.c();
2053
- });
2054
- }
2055
- function loadFailed(scope, awaitCounter) {
2056
- return (error) => {
2057
- if (awaitCounter) awaitCounter.i = 0;
2058
- queueAsyncRender(scope, renderCatch, error);
2059
2063
  };
2060
- }
2061
- function applyLoad(scope, insert) {
2062
- const values = scope["#Load"];
2063
2064
  let remaining;
2064
- scope["#Load"] = 0;
2065
+ syncGen(branch);
2066
+ renderer["clone"](branch, parent.namespaceURI);
2067
+ branch["#Load"] = 0;
2065
2068
  if (remaining = values?.size) for (const [promise, entry] of values) promise.then((signal) => {
2066
2069
  entry["signal"] = signal;
2067
- if (!--remaining) queueAsyncRender(scope, (scope) => {
2068
- syncGen(scope);
2069
- 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"]));
2070
2074
  insert();
2071
2075
  });
2072
2076
  }, () => 0);
2073
- 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
+ };
2074
2087
  }
2075
2088
  function _load_signal(load) {
2076
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;
@@ -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, 1);
2533
- else if ("checkedValue" in data || data.checkedValueChange) result += _attr_input_checkedValue(scopeId, nodeAccessor, data.checkedValue, data.checkedValueChange, data.value, 1);
2534
- else if (data.valueChange) result += _attr_input_value(scopeId, nodeAccessor, data.value, data.valueChange, 1);
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":
@@ -875,8 +875,11 @@ function writeDate(state, val) {
875
875
  state.buf.push("new Date(" + +val + ")");
876
876
  return true;
877
877
  }
878
+ const unsafeRegExpSourceReg = /\\[\s\S]|</g;
879
+ const replaceUnsafeRegExpSourceChar = (match) => match === "<" || match === "\\<" ? "\\x3C" : match;
878
880
  function writeRegExp(state, val) {
879
- state.buf.push(val + "");
881
+ const { source } = val;
882
+ state.buf.push("/" + (source.includes("<") ? source.replace(unsafeRegExpSourceReg, replaceUnsafeRegExpSourceChar) : source) + "/" + val.flags);
880
883
  return true;
881
884
  }
882
885
  function writePromise(state, val, ref) {
@@ -1006,7 +1009,7 @@ function writeWeakMap(state) {
1006
1009
  }
1007
1010
  function writeError(state, val, ref) {
1008
1011
  const result = "new " + val.constructor.name + "(" + quote(val.message + "", 0);
1009
- if (val.cause) {
1012
+ if (val.cause !== void 0) {
1010
1013
  state.buf.push(result + ",{cause:");
1011
1014
  writeProp(state, val.cause, ref, "cause");
1012
1015
  state.buf.push("})");
@@ -2462,7 +2465,8 @@ function _attr_style(value) {
2462
2465
  }
2463
2466
  function _attr_option_value(value) {
2464
2467
  const valueAttr = _attr("value", value);
2465
- if (normalizedValueMatches(getContext(kSelectedValue), value)) {
2468
+ const selectedValue = getContext(kSelectedValue);
2469
+ if (selectedValue !== void 0 && normalizedValueMatches(selectedValue, value)) {
2466
2470
  {
2467
2471
  const matched = getContext(kSelectedValueMatched);
2468
2472
  if (matched) matched.value = true;
@@ -2527,11 +2531,16 @@ function _attrs(data, nodeAccessor, scopeId, tagName) {
2527
2531
  switch (tagName) {
2528
2532
  case "input":
2529
2533
  assertExclusiveAttrs(data);
2530
- if (data.checkedChange) result += _attr_input_checked(scopeId, nodeAccessor, data.checked, data.checkedChange, 1);
2531
- else if ("checkedValue" in data || data.checkedValueChange) result += _attr_input_checkedValue(scopeId, nodeAccessor, data.checkedValue, data.checkedValueChange, data.value, 1);
2532
- else if (data.valueChange) result += _attr_input_value(scopeId, nodeAccessor, data.value, data.valueChange, 1);
2533
- else break;
2534
- skip = /^(?:value|checked(?:Value)?)(?:Change)?$|[\s/>"'=]/;
2534
+ if (data.checkedChange) {
2535
+ result += _attr_input_checked(scopeId, nodeAccessor, data.checked, data.checkedChange, 1);
2536
+ skip = /^checked(?:Value)?(?:Change)?$|[\s/>"'=]/;
2537
+ } else if ("checkedValue" in data || data.checkedValueChange) {
2538
+ result += _attr_input_checkedValue(scopeId, nodeAccessor, data.checkedValue, data.checkedValueChange, data.value, 1);
2539
+ skip = /^(?:value|checked(?:Value)?)(?:Change)?$|[\s/>"'=]/;
2540
+ } else if (data.valueChange) {
2541
+ result += _attr_input_value(scopeId, nodeAccessor, data.value, data.valueChange, 1);
2542
+ skip = /^value(?:Change)?$|[\s/>"'=]/;
2543
+ } else break;
2535
2544
  break;
2536
2545
  case "select":
2537
2546
  case "textarea":
package/dist/dom.js CHANGED
@@ -98,7 +98,7 @@ let empty = [], rest = Symbol(), toDelimitedString = function toDelimitedString(
98
98
  },
99
99
  render(out, component, renderer, args) {
100
100
  let branch = component.scope, created = 0;
101
- if (!branch && (branch = classIdToBranch.get(component.id)) && (component.scope = branch, classIdToBranch.delete(component.id)), typeof args[0] == "object" && "renderBody" in args[0]) {
101
+ if (!branch && (branch = classIdToBranch.get(component.id)) && (component.scope = branch, classIdToBranch.delete(component.id)), args[0] && typeof args[0] == "object" && "renderBody" in args[0]) {
102
102
  let input = args[0], normalizedInput = args[0] = {};
103
103
  for (let key in input) normalizedInput[key === "renderBody" ? "content" : key] = input[key];
104
104
  }
@@ -457,20 +457,24 @@ function init(runtimeId = "M") {
457
457
  let partial = partials[i];
458
458
  typeof partial == "number" ? scopeId += partial : (scopeId ? initScope(Object.assign(scopeLookup[scopeId] ||= (partial.L = scopeId, partial), partial)) : Object.assign(initGlobal(), partial), scopeId++);
459
459
  }
460
- }, serializeContext = ((data, registryId) => typeof data == "number" ? registryId ? registeredValues[registryId](getScope(data)) : getScope(data) : applyScopes(data)), createVisitBranches = (branchScopesStack = [], branchStarts = [], orphanBranches = [], curBranchScopes) => (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length) => {
460
+ }, serializeContext = ((data, registryId) => typeof data == "number" ? registryId ? registeredValues[registryId](getScope(data)) : getScope(data) : applyScopes(data)), createVisitBranches = (branchScopesStack = [], branchStarts = [], orphanBranches = [], deferredOwners = [], curBranchScopes) => (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length, j = deferredOwners.length) => {
461
461
  for (visitType !== "[" && (visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit, accessor = "A" + lastToken, singleNode = visitType !== "]" && visitType !== ")", nextToken()); branchId = +lastToken;) {
462
462
  if ((endedBranches ||= []).push(branch = getScope(branchId)), setParentBranch(branch, branch.F), (branch.O = render.p?.[branchId]) && (branch.O.m = render.m), singleNode) {
463
463
  for (; startVisit.previousSibling && ~visits.indexOf(startVisit = startVisit.previousSibling););
464
464
  branch.K = branch.S = startVisit, visitType === "'" && (branch.a = startVisit);
465
465
  } else curBranchScopes = push(curBranchScopes, branch), accessor && (visitScope[accessor] = curBranchScopes, curBranchScopes = branchScopesStack.pop()), startVisit = branchStarts.pop(), parent !== startVisit.parentNode && parent.prepend(startVisit), branch.S = startVisit, branch.K = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
466
466
  for (; i && orphanBranches[--i].L > branchId;) setParentBranch(orphanBranches.pop(), branch);
467
+ for (; j && deferredOwners[--j].L > branchId;) {
468
+ let owner = deferredOwners.pop();
469
+ owner.F !== owner && (owner.F = branch);
470
+ }
467
471
  nextToken();
468
472
  }
469
473
  if (endedBranches) {
470
474
  for (let ended of endedBranches) orphanBranches.push(ended);
471
475
  singleNode && (visitScope[accessor] = endedBranches.length > 1 ? endedBranches.reverse() : endedBranches[0]);
472
476
  }
473
- visitType === "[" && (endedBranches || (branchScopesStack.push(curBranchScopes), curBranchScopes = void 0), branchStarts.push(visit));
477
+ visitType === "[" ? (endedBranches || (branchScopesStack.push(curBranchScopes), curBranchScopes = void 0), branchStarts.push(visit)) : deferredOwners.push(visitScope);
474
478
  }, nextToken = () => lastToken = visitText.slice(lastTokenIndex, (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1), processResumes = (resumes = [], effects) => {
475
479
  let i = 0;
476
480
  for (; i < resumes.length; i++) {
@@ -773,11 +777,10 @@ function attrsInternal(scope, nodeAccessor, nextAttrs) {
773
777
  for (let name in events) events[name] = 0;
774
778
  switch (scope["F" + nodeAccessor] = 5, scope["E" + nodeAccessor] = 0, el.tagName) {
775
779
  case "INPUT":
776
- if ("checked" in nextAttrs || "checkedChange" in nextAttrs) _attr_input_checked(scope, nodeAccessor, nextAttrs.checked, nextAttrs.checkedChange);
777
- else if ("checkedValue" in nextAttrs || "checkedValueChange" in nextAttrs) _attr_input_checkedValue(scope, nodeAccessor, nextAttrs.checkedValue, nextAttrs.checkedValueChange, nextAttrs.value);
778
- else if ("value" in nextAttrs || "valueChange" in nextAttrs) _attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange);
780
+ if ("checked" in nextAttrs || "checkedChange" in nextAttrs) _attr_input_checked(scope, nodeAccessor, nextAttrs.checked, nextAttrs.checkedChange), skip = /^checked(?:Value)?(?:Change)?$/;
781
+ else if ("checkedValue" in nextAttrs || "checkedValueChange" in nextAttrs) _attr_input_checkedValue(scope, nodeAccessor, nextAttrs.checkedValue, nextAttrs.checkedValueChange, nextAttrs.value), skip = /^(?:value|checked(?:Value)?)(?:Change)?$/;
782
+ else if ("value" in nextAttrs || "valueChange" in nextAttrs) _attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange), skip = /^value(?:Change)?$/;
779
783
  else break;
780
- skip = /^(?:value|checked(?:Value)?)(?:Change)?$/;
781
784
  break;
782
785
  case "SELECT":
783
786
  ("value" in nextAttrs || "valueChange" in nextAttrs) && (_attr_select_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange), skip = /^value(?:Change)?$/);
@@ -884,7 +887,14 @@ function _await_promise(nodeAccessor, params) {
884
887
  i: 0,
885
888
  c() {
886
889
  if (--awaitCounter.i) return 1;
887
- tryBranch === scope[branchAccessor] ? scope[nodeAccessor].parentNode && scope[nodeAccessor].replaceWith(scope[branchAccessor].S.parentNode) : dismissPlaceholder(tryBranch), queueEffect(tryBranch, runPendingEffects);
890
+ if (tryBranch === scope[branchAccessor]) {
891
+ let anchor = scope[nodeAccessor];
892
+ if (anchor.parentNode) {
893
+ let detachedParent = scope[branchAccessor].S.parentNode;
894
+ detachedParent === anchor.parentNode ? anchor.remove() : anchor.replaceWith(detachedParent);
895
+ }
896
+ } else dismissPlaceholder(tryBranch);
897
+ queueEffect(tryBranch, runPendingEffects);
888
898
  }
889
899
  }), scope[promiseAccessor] || (awaitBranch && (awaitBranch.W ||= []), awaitCounter.i++ || requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(scope, () => {
890
900
  awaitBranch.V || (awaitBranch.S.parentNode.insertBefore(scope[nodeAccessor], awaitBranch.S), tempDetachBranch(tryBranch));
@@ -1224,25 +1234,21 @@ function _load_setup(nodeAccessor, childScopeAccessor, load) {
1224
1234
  };
1225
1235
  }
1226
1236
  function insertLoaded(renderer, branch, marker, awaitCounter) {
1227
- let parent = marker.parentNode;
1228
- syncGen(branch), renderer.b(branch, parent.namespaceURI), setupBranch(renderer, branch), applyLoad(branch, () => {
1237
+ let parent = marker.parentNode, values = branch.X, insert = () => {
1229
1238
  insertBranchBefore(branch, parent, marker), marker.remove(), awaitCounter?.c();
1230
- });
1239
+ }, remaining;
1240
+ if (syncGen(branch), renderer.b(branch, parent.namespaceURI), branch.X = 0, remaining = values?.size) for (let [promise, entry] of values) promise.then((signal) => {
1241
+ entry.b = signal, --remaining || queueAsyncRender(branch, (branch) => {
1242
+ syncGen(branch), renderer.c?.(branch), values.forEach((e) => e.b._(branch, e.a)), insert();
1243
+ });
1244
+ }, () => 0);
1245
+ else setupBranch(renderer, branch), insert();
1231
1246
  }
1232
1247
  function loadFailed(scope, awaitCounter) {
1233
1248
  return (error) => {
1234
1249
  awaitCounter && (awaitCounter.i = 0), queueAsyncRender(scope, renderCatch, error);
1235
1250
  };
1236
1251
  }
1237
- function applyLoad(scope, insert) {
1238
- let values = scope.X, remaining;
1239
- if (scope.X = 0, remaining = values?.size) for (let [promise, entry] of values) promise.then((signal) => {
1240
- entry.b = signal, --remaining || queueAsyncRender(scope, (scope) => {
1241
- syncGen(scope), values.forEach((e) => e.b._(scope, e.a)), insert();
1242
- });
1243
- }, () => 0);
1244
- else insert();
1245
- }
1246
1252
  function _load_signal(load) {
1247
1253
  let pending, signal;
1248
1254
  return (scope, value) => {
package/dist/dom.mjs CHANGED
@@ -98,7 +98,7 @@ let empty = [], rest = Symbol(), toDelimitedString = function toDelimitedString(
98
98
  },
99
99
  render(out, component, renderer, args) {
100
100
  let branch = component.scope, created = 0;
101
- if (!branch && (branch = classIdToBranch.get(component.id)) && (component.scope = branch, classIdToBranch.delete(component.id)), typeof args[0] == "object" && "renderBody" in args[0]) {
101
+ if (!branch && (branch = classIdToBranch.get(component.id)) && (component.scope = branch, classIdToBranch.delete(component.id)), args[0] && typeof args[0] == "object" && "renderBody" in args[0]) {
102
102
  let input = args[0], normalizedInput = args[0] = {};
103
103
  for (let key in input) normalizedInput[key === "renderBody" ? "content" : key] = input[key];
104
104
  }
@@ -456,20 +456,24 @@ function init(runtimeId = "M") {
456
456
  let partial = partials[i];
457
457
  typeof partial == "number" ? scopeId += partial : (scopeId ? initScope(Object.assign(scopeLookup[scopeId] ||= (partial.L = scopeId, partial), partial)) : Object.assign(initGlobal(), partial), scopeId++);
458
458
  }
459
- }, serializeContext = ((data, registryId) => typeof data == "number" ? registryId ? registeredValues[registryId](getScope(data)) : getScope(data) : applyScopes(data)), createVisitBranches = (branchScopesStack = [], branchStarts = [], orphanBranches = [], curBranchScopes) => (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length) => {
459
+ }, serializeContext = ((data, registryId) => typeof data == "number" ? registryId ? registeredValues[registryId](getScope(data)) : getScope(data) : applyScopes(data)), createVisitBranches = (branchScopesStack = [], branchStarts = [], orphanBranches = [], deferredOwners = [], curBranchScopes) => (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length, j = deferredOwners.length) => {
460
460
  for (visitType !== "[" && (visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit, accessor = "A" + lastToken, singleNode = visitType !== "]" && visitType !== ")", nextToken()); branchId = +lastToken;) {
461
461
  if ((endedBranches ||= []).push(branch = getScope(branchId)), setParentBranch(branch, branch.F), (branch.O = render.p?.[branchId]) && (branch.O.m = render.m), singleNode) {
462
462
  for (; startVisit.previousSibling && ~visits.indexOf(startVisit = startVisit.previousSibling););
463
463
  branch.K = branch.S = startVisit, visitType === "'" && (branch.a = startVisit);
464
464
  } else curBranchScopes = push(curBranchScopes, branch), accessor && (visitScope[accessor] = curBranchScopes, curBranchScopes = branchScopesStack.pop()), startVisit = branchStarts.pop(), parent !== startVisit.parentNode && parent.prepend(startVisit), branch.S = startVisit, branch.K = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
465
465
  for (; i && orphanBranches[--i].L > branchId;) setParentBranch(orphanBranches.pop(), branch);
466
+ for (; j && deferredOwners[--j].L > branchId;) {
467
+ let owner = deferredOwners.pop();
468
+ owner.F !== owner && (owner.F = branch);
469
+ }
466
470
  nextToken();
467
471
  }
468
472
  if (endedBranches) {
469
473
  for (let ended of endedBranches) orphanBranches.push(ended);
470
474
  singleNode && (visitScope[accessor] = endedBranches.length > 1 ? endedBranches.reverse() : endedBranches[0]);
471
475
  }
472
- visitType === "[" && (endedBranches || (branchScopesStack.push(curBranchScopes), curBranchScopes = void 0), branchStarts.push(visit));
476
+ visitType === "[" ? (endedBranches || (branchScopesStack.push(curBranchScopes), curBranchScopes = void 0), branchStarts.push(visit)) : deferredOwners.push(visitScope);
473
477
  }, nextToken = () => lastToken = visitText.slice(lastTokenIndex, (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1), processResumes = (resumes = [], effects) => {
474
478
  let i = 0;
475
479
  for (; i < resumes.length; i++) {
@@ -772,11 +776,10 @@ function attrsInternal(scope, nodeAccessor, nextAttrs) {
772
776
  for (let name in events) events[name] = 0;
773
777
  switch (scope["F" + nodeAccessor] = 5, scope["E" + nodeAccessor] = 0, el.tagName) {
774
778
  case "INPUT":
775
- if ("checked" in nextAttrs || "checkedChange" in nextAttrs) _attr_input_checked(scope, nodeAccessor, nextAttrs.checked, nextAttrs.checkedChange);
776
- else if ("checkedValue" in nextAttrs || "checkedValueChange" in nextAttrs) _attr_input_checkedValue(scope, nodeAccessor, nextAttrs.checkedValue, nextAttrs.checkedValueChange, nextAttrs.value);
777
- else if ("value" in nextAttrs || "valueChange" in nextAttrs) _attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange);
779
+ if ("checked" in nextAttrs || "checkedChange" in nextAttrs) _attr_input_checked(scope, nodeAccessor, nextAttrs.checked, nextAttrs.checkedChange), skip = /^checked(?:Value)?(?:Change)?$/;
780
+ else if ("checkedValue" in nextAttrs || "checkedValueChange" in nextAttrs) _attr_input_checkedValue(scope, nodeAccessor, nextAttrs.checkedValue, nextAttrs.checkedValueChange, nextAttrs.value), skip = /^(?:value|checked(?:Value)?)(?:Change)?$/;
781
+ else if ("value" in nextAttrs || "valueChange" in nextAttrs) _attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange), skip = /^value(?:Change)?$/;
778
782
  else break;
779
- skip = /^(?:value|checked(?:Value)?)(?:Change)?$/;
780
783
  break;
781
784
  case "SELECT":
782
785
  ("value" in nextAttrs || "valueChange" in nextAttrs) && (_attr_select_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange), skip = /^value(?:Change)?$/);
@@ -883,7 +886,14 @@ function _await_promise(nodeAccessor, params) {
883
886
  i: 0,
884
887
  c() {
885
888
  if (--awaitCounter.i) return 1;
886
- tryBranch === scope[branchAccessor] ? scope[nodeAccessor].parentNode && scope[nodeAccessor].replaceWith(scope[branchAccessor].S.parentNode) : dismissPlaceholder(tryBranch), queueEffect(tryBranch, runPendingEffects);
889
+ if (tryBranch === scope[branchAccessor]) {
890
+ let anchor = scope[nodeAccessor];
891
+ if (anchor.parentNode) {
892
+ let detachedParent = scope[branchAccessor].S.parentNode;
893
+ detachedParent === anchor.parentNode ? anchor.remove() : anchor.replaceWith(detachedParent);
894
+ }
895
+ } else dismissPlaceholder(tryBranch);
896
+ queueEffect(tryBranch, runPendingEffects);
887
897
  }
888
898
  }), scope[promiseAccessor] || (awaitBranch && (awaitBranch.W ||= []), awaitCounter.i++ || requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(scope, () => {
889
899
  awaitBranch.V || (awaitBranch.S.parentNode.insertBefore(scope[nodeAccessor], awaitBranch.S), tempDetachBranch(tryBranch));
@@ -1223,25 +1233,21 @@ function _load_setup(nodeAccessor, childScopeAccessor, load) {
1223
1233
  };
1224
1234
  }
1225
1235
  function insertLoaded(renderer, branch, marker, awaitCounter) {
1226
- let parent = marker.parentNode;
1227
- syncGen(branch), renderer.b(branch, parent.namespaceURI), setupBranch(renderer, branch), applyLoad(branch, () => {
1236
+ let parent = marker.parentNode, values = branch.X, insert = () => {
1228
1237
  insertBranchBefore(branch, parent, marker), marker.remove(), awaitCounter?.c();
1229
- });
1238
+ }, remaining;
1239
+ if (syncGen(branch), renderer.b(branch, parent.namespaceURI), branch.X = 0, remaining = values?.size) for (let [promise, entry] of values) promise.then((signal) => {
1240
+ entry.b = signal, --remaining || queueAsyncRender(branch, (branch) => {
1241
+ syncGen(branch), renderer.c?.(branch), values.forEach((e) => e.b._(branch, e.a)), insert();
1242
+ });
1243
+ }, () => 0);
1244
+ else setupBranch(renderer, branch), insert();
1230
1245
  }
1231
1246
  function loadFailed(scope, awaitCounter) {
1232
1247
  return (error) => {
1233
1248
  awaitCounter && (awaitCounter.i = 0), queueAsyncRender(scope, renderCatch, error);
1234
1249
  };
1235
1250
  }
1236
- function applyLoad(scope, insert) {
1237
- let values = scope.X, remaining;
1238
- if (scope.X = 0, remaining = values?.size) for (let [promise, entry] of values) promise.then((signal) => {
1239
- entry.b = signal, --remaining || queueAsyncRender(scope, (scope) => {
1240
- syncGen(scope), values.forEach((e) => e.b._(scope, e.a)), insert();
1241
- });
1242
- }, () => 0);
1243
- else insert();
1244
- }
1245
1251
  function _load_signal(load) {
1246
1252
  let pending, signal;
1247
1253
  return (scope, value) => {
package/dist/html.js CHANGED
@@ -238,7 +238,7 @@ let empty = [], rest = Symbol(), toDelimitedString = function toDelimitedString(
238
238
  [JSON, "JSON"],
239
239
  [Math, "Math"],
240
240
  [Reflect, "Reflect"]
241
- ]), $chunk, NOOP$2 = () => {}, kPendingContexts = Symbol("Pending Contexts"), kBranchId = Symbol("Branch Id"), kIsAsync = Symbol("Is Async"), writeScope = (scopeId, partialScope) => {
241
+ ]), unsafeRegExpSourceReg = /\\[\s\S]|</g, replaceUnsafeRegExpSourceChar = (match) => match === "<" || match === "\\<" ? "\\x3C" : match, $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) => {
@@ -691,7 +691,8 @@ function writeDate(state, val) {
691
691
  return state.buf.push("new Date(" + +val + ")"), !0;
692
692
  }
693
693
  function writeRegExp(state, val) {
694
- return state.buf.push(val + ""), !0;
694
+ let { source } = val;
695
+ return state.buf.push("/" + (source.includes("<") ? source.replace(unsafeRegExpSourceReg, replaceUnsafeRegExpSourceChar) : source) + "/" + val.flags), !0;
695
696
  }
696
697
  function writePromise(state, val, ref) {
697
698
  let { boundary, channel } = state;
@@ -760,7 +761,7 @@ function writeWeakMap(state) {
760
761
  }
761
762
  function writeError(state, val, ref) {
762
763
  let result = "new " + val.constructor.name + "(" + quote(val.message + "", 0);
763
- return val.cause ? (state.buf.push(result + ",{cause:"), writeProp(state, val.cause, ref, "cause"), state.buf.push("})")) : state.buf.push(result + ")"), !0;
764
+ return val.cause === void 0 ? state.buf.push(result + ")") : (state.buf.push(result + ",{cause:"), writeProp(state, val.cause, ref, "cause"), state.buf.push("})")), !0;
764
765
  }
765
766
  function writeAggregateError(state, val, ref) {
766
767
  return state.buf.push("new AggregateError("), writeProp(state, val.errors, ref, "errors"), val.message ? state.buf.push("," + quote(val.message + "", 0) + ")") : state.buf.push(")"), !0;
@@ -1611,8 +1612,8 @@ function _attr_style(value) {
1611
1612
  return stringAttr("style", toDelimitedString(value, ";", stringifyStyleObject));
1612
1613
  }
1613
1614
  function _attr_option_value(value) {
1614
- let valueAttr = _attr("value", value);
1615
- return normalizedValueMatches(getContext(kSelectedValue), value) ? valueAttr + " selected" : valueAttr;
1615
+ let valueAttr = _attr("value", value), selectedValue = getContext(kSelectedValue);
1616
+ return selectedValue !== void 0 && normalizedValueMatches(selectedValue, value) ? valueAttr + " selected" : valueAttr;
1616
1617
  }
1617
1618
  function _attr_select_value(scopeId, nodeAccessor, value, valueChange, content, serializeType) {
1618
1619
  valueChange && writeControlledScope(3, scopeId, nodeAccessor, void 0, valueChange, serializeType), content && withContext(kSelectedValue, value, content);
@@ -1650,11 +1651,10 @@ function _attrs(data, nodeAccessor, scopeId, tagName) {
1650
1651
  let result = "", skip = /[\s/>"'=]/, events;
1651
1652
  switch (tagName) {
1652
1653
  case "input":
1653
- if (data.checkedChange) result += _attr_input_checked(scopeId, nodeAccessor, data.checked, data.checkedChange, 1);
1654
- else if ("checkedValue" in data || data.checkedValueChange) result += _attr_input_checkedValue(scopeId, nodeAccessor, data.checkedValue, data.checkedValueChange, data.value, 1);
1655
- else if (data.valueChange) result += _attr_input_value(scopeId, nodeAccessor, data.value, data.valueChange, 1);
1654
+ if (data.checkedChange) result += _attr_input_checked(scopeId, nodeAccessor, data.checked, data.checkedChange, 1), skip = /^checked(?:Value)?(?:Change)?$|[\s/>"'=]/;
1655
+ else if ("checkedValue" in data || data.checkedValueChange) result += _attr_input_checkedValue(scopeId, nodeAccessor, data.checkedValue, data.checkedValueChange, data.value, 1), skip = /^(?:value|checked(?:Value)?)(?:Change)?$|[\s/>"'=]/;
1656
+ else if (data.valueChange) result += _attr_input_value(scopeId, nodeAccessor, data.value, data.valueChange, 1), skip = /^value(?:Change)?$|[\s/>"'=]/;
1656
1657
  else break;
1657
- skip = /^(?:value|checked(?:Value)?)(?:Change)?$|[\s/>"'=]/;
1658
1658
  break;
1659
1659
  case "select":
1660
1660
  case "textarea":
package/dist/html.mjs CHANGED
@@ -238,7 +238,7 @@ let empty = [], rest = Symbol(), toDelimitedString = function toDelimitedString(
238
238
  [JSON, "JSON"],
239
239
  [Math, "Math"],
240
240
  [Reflect, "Reflect"]
241
- ]), $chunk, NOOP$2 = () => {}, kPendingContexts = Symbol("Pending Contexts"), kBranchId = Symbol("Branch Id"), kIsAsync = Symbol("Is Async"), writeScope = (scopeId, partialScope) => {
241
+ ]), unsafeRegExpSourceReg = /\\[\s\S]|</g, replaceUnsafeRegExpSourceChar = (match) => match === "<" || match === "\\<" ? "\\x3C" : match, $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) => {
@@ -690,7 +690,8 @@ function writeDate(state, val) {
690
690
  return state.buf.push("new Date(" + +val + ")"), !0;
691
691
  }
692
692
  function writeRegExp(state, val) {
693
- return state.buf.push(val + ""), !0;
693
+ let { source } = val;
694
+ return state.buf.push("/" + (source.includes("<") ? source.replace(unsafeRegExpSourceReg, replaceUnsafeRegExpSourceChar) : source) + "/" + val.flags), !0;
694
695
  }
695
696
  function writePromise(state, val, ref) {
696
697
  let { boundary, channel } = state;
@@ -759,7 +760,7 @@ function writeWeakMap(state) {
759
760
  }
760
761
  function writeError(state, val, ref) {
761
762
  let result = "new " + val.constructor.name + "(" + quote(val.message + "", 0);
762
- return val.cause ? (state.buf.push(result + ",{cause:"), writeProp(state, val.cause, ref, "cause"), state.buf.push("})")) : state.buf.push(result + ")"), !0;
763
+ return val.cause === void 0 ? state.buf.push(result + ")") : (state.buf.push(result + ",{cause:"), writeProp(state, val.cause, ref, "cause"), state.buf.push("})")), !0;
763
764
  }
764
765
  function writeAggregateError(state, val, ref) {
765
766
  return state.buf.push("new AggregateError("), writeProp(state, val.errors, ref, "errors"), val.message ? state.buf.push("," + quote(val.message + "", 0) + ")") : state.buf.push(")"), !0;
@@ -1610,8 +1611,8 @@ function _attr_style(value) {
1610
1611
  return stringAttr("style", toDelimitedString(value, ";", stringifyStyleObject));
1611
1612
  }
1612
1613
  function _attr_option_value(value) {
1613
- let valueAttr = _attr("value", value);
1614
- return normalizedValueMatches(getContext(kSelectedValue), value) ? valueAttr + " selected" : valueAttr;
1614
+ let valueAttr = _attr("value", value), selectedValue = getContext(kSelectedValue);
1615
+ return selectedValue !== void 0 && normalizedValueMatches(selectedValue, value) ? valueAttr + " selected" : valueAttr;
1615
1616
  }
1616
1617
  function _attr_select_value(scopeId, nodeAccessor, value, valueChange, content, serializeType) {
1617
1618
  valueChange && writeControlledScope(3, scopeId, nodeAccessor, void 0, valueChange, serializeType), content && withContext(kSelectedValue, value, content);
@@ -1649,11 +1650,10 @@ function _attrs(data, nodeAccessor, scopeId, tagName) {
1649
1650
  let result = "", skip = /[\s/>"'=]/, events;
1650
1651
  switch (tagName) {
1651
1652
  case "input":
1652
- if (data.checkedChange) result += _attr_input_checked(scopeId, nodeAccessor, data.checked, data.checkedChange, 1);
1653
- else if ("checkedValue" in data || data.checkedValueChange) result += _attr_input_checkedValue(scopeId, nodeAccessor, data.checkedValue, data.checkedValueChange, data.value, 1);
1654
- else if (data.valueChange) result += _attr_input_value(scopeId, nodeAccessor, data.value, data.valueChange, 1);
1653
+ if (data.checkedChange) result += _attr_input_checked(scopeId, nodeAccessor, data.checked, data.checkedChange, 1), skip = /^checked(?:Value)?(?:Change)?$|[\s/>"'=]/;
1654
+ else if ("checkedValue" in data || data.checkedValueChange) result += _attr_input_checkedValue(scopeId, nodeAccessor, data.checkedValue, data.checkedValueChange, data.value, 1), skip = /^(?:value|checked(?:Value)?)(?:Change)?$|[\s/>"'=]/;
1655
+ else if (data.valueChange) result += _attr_input_value(scopeId, nodeAccessor, data.value, data.valueChange, 1), skip = /^value(?:Change)?$|[\s/>"'=]/;
1655
1656
  else break;
1656
- skip = /^(?:value|checked(?:Value)?)(?:Change)?$|[\s/>"'=]/;
1657
1657
  break;
1658
1658
  case "select":
1659
1659
  case "textarea":
@@ -25,7 +25,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  let package_json = require("../../package.json");
26
26
  let _marko_compiler = require("@marko/compiler");
27
27
  let _marko_compiler_babel_utils = require("@marko/compiler/babel-utils");
28
- let _marko_compiler_config = require("@marko/compiler/config");
29
28
  let node_path = require("node:path");
30
29
  node_path = __toESM(node_path);
31
30
  let path = require("path");
@@ -1765,13 +1764,13 @@ function getBindingPropTree(binding) {
1765
1764
  };
1766
1765
  if (!binding.reads.size) {
1767
1766
  if (!binding.aliases.size) {
1768
- props.props = {};
1767
+ props.props = Object.create(null);
1769
1768
  for (const [property, alias] of binding.propertyAliases) props.props[property] = getBindingPropTree(alias);
1770
1769
  } else if (binding.aliases.size === 1) {
1771
1770
  const [restAlias] = binding.aliases;
1772
1771
  if (hasSupersetExcludeProperties(binding, restAlias.excludeProperties)) {
1773
1772
  props.rest = getBindingPropTree(restAlias);
1774
- props.props = {};
1773
+ props.props = Object.create(null);
1775
1774
  if (restAlias.type === 2) restAlias.export ??= generateUid(restAlias.name);
1776
1775
  forEach(restAlias.excludeProperties, (property) => {
1777
1776
  const propAlias = binding.propertyAliases.get(property);
@@ -2013,7 +2012,8 @@ function _attr_style(value) {
2013
2012
  }
2014
2013
  function _attr_option_value(value) {
2015
2014
  const valueAttr = _attr("value", value);
2016
- if (normalizedValueMatches(getContext(kSelectedValue), value)) return valueAttr + " selected";
2015
+ const selectedValue = getContext(kSelectedValue);
2016
+ if (selectedValue !== void 0 && normalizedValueMatches(selectedValue, value)) return valueAttr + " selected";
2017
2017
  return valueAttr;
2018
2018
  }
2019
2019
  const kSelectedValue = Symbol("selectedValue");
@@ -2063,11 +2063,16 @@ function _attrs(data, nodeAccessor, scopeId, tagName) {
2063
2063
  let events;
2064
2064
  switch (tagName) {
2065
2065
  case "input":
2066
- if (data.checkedChange) result += _attr_input_checked(scopeId, nodeAccessor, data.checked, data.checkedChange, 1);
2067
- else if ("checkedValue" in data || data.checkedValueChange) result += _attr_input_checkedValue(scopeId, nodeAccessor, data.checkedValue, data.checkedValueChange, data.value, 1);
2068
- else if (data.valueChange) result += _attr_input_value(scopeId, nodeAccessor, data.value, data.valueChange, 1);
2069
- else break;
2070
- skip = /^(?:value|checked(?:Value)?)(?:Change)?$|[\s/>"'=]/;
2066
+ if (data.checkedChange) {
2067
+ result += _attr_input_checked(scopeId, nodeAccessor, data.checked, data.checkedChange, 1);
2068
+ skip = /^checked(?:Value)?(?:Change)?$|[\s/>"'=]/;
2069
+ } else if ("checkedValue" in data || data.checkedValueChange) {
2070
+ result += _attr_input_checkedValue(scopeId, nodeAccessor, data.checkedValue, data.checkedValueChange, data.value, 1);
2071
+ skip = /^(?:value|checked(?:Value)?)(?:Change)?$|[\s/>"'=]/;
2072
+ } else if (data.valueChange) {
2073
+ result += _attr_input_value(scopeId, nodeAccessor, data.value, data.valueChange, 1);
2074
+ skip = /^value(?:Change)?$|[\s/>"'=]/;
2075
+ } else break;
2071
2076
  break;
2072
2077
  case "select":
2073
2078
  case "textarea":
@@ -4073,8 +4078,7 @@ function analyzeAttributeTags(tag) {
4073
4078
  }
4074
4079
  let attrTagMeta = lookup[name];
4075
4080
  if (!attrTagMeta) {
4076
- attrTagMeta = lookup[name] = createAttrTagMeta(name, []);
4077
- curGroup = attrTagMeta.group;
4081
+ attrTagMeta = lookup[name] = createAttrTagMeta(name, curGroup ||= []);
4078
4082
  curGroup.push(name);
4079
4083
  }
4080
4084
  attrTagMeta.dynamic = true;
@@ -6923,7 +6927,7 @@ function getReadReplacement(node, signal) {
6923
6927
  else if (read.getter?.hoisted) replacement = _marko_compiler.types.callExpression(getBindingGetterIdentifier(readBinding, read.getter.hoisted), [getScopeExpression(extra.section, read.getter.hoisted)]);
6924
6928
  else if (readBinding.type === 0) {
6925
6929
  if (read.getter) replacement = _marko_compiler.types.callExpression(getBindingGetterIdentifier(readBinding, readBinding.section), [getScopeExpression(extra.section, readBinding.section)]);
6926
- } else if (!_marko_compiler_config.optimize && read.ownVar) replacement = callRuntime("_assert_init", extra.section ? getScopeExpression(extra.section, readBinding.section) : scopeIdentifier, getScopeAccessorLiteral(readBinding));
6930
+ } else if (!isOptimize() && read.ownVar) replacement = callRuntime("_assert_init", extra.section ? getScopeExpression(extra.section, readBinding.section) : scopeIdentifier, getScopeAccessorLiteral(readBinding));
6927
6931
  else replacement = createScopeReadExpression(readBinding, extra.section);
6928
6932
  else if (node.type !== "Identifier") replacement = _marko_compiler.types.identifier(readBinding.name);
6929
6933
  else if (read.getter?.hoisted) replacement = getBindingGetterIdentifier(readBinding, read.getter.hoisted);
@@ -7986,9 +7990,9 @@ var style_default = {
7986
7990
  (0, _marko_compiler_babel_utils.assertNoParams)(tag);
7987
7991
  (0, _marko_compiler_babel_utils.assertNoAttributeTags)(tag);
7988
7992
  const { node, hub: { file } } = tag;
7989
- const ext = STYLE_EXT_REG.exec(node.rawValue || "")?.[1]?.slice(1);
7993
+ const extClass = (STYLE_EXT_REG.exec(node.rawValue || "")?.[1]?.slice(1))?.replace(/\./g, " ");
7990
7994
  for (const attr of node.attributes) {
7991
- if (attr.start == null && attr.type === "MarkoAttribute" && attr.name === "class" && attr.value.type === "StringLiteral" && attr.value.value === ext) continue;
7995
+ if (attr.start == null && attr.type === "MarkoAttribute" && attr.name === "class" && attr.value.type === "StringLiteral" && attr.value.value === extClass) continue;
7992
7996
  throw tag.hub.buildError(attr.value, "The `style` does not support html attributes." + htmlStyleTagAlternateMsg);
7993
7997
  }
7994
7998
  for (const child of node.body.body) if (child.type !== "MarkoText") throw tag.hub.buildError(child, "The [`<style>` tag](https://markojs.com/docs/reference/core-tag#style) currently only supports static content." + htmlStyleTagAlternateMsg);
@@ -8485,7 +8489,7 @@ var referenced_identifier_default = {
8485
8489
  abortIdsByExpression = /* @__PURE__ */ new Map();
8486
8490
  abortIdsByExpressionForSection.set(section, abortIdsByExpression);
8487
8491
  }
8488
- if (!exprId) {
8492
+ if (exprId === void 0) {
8489
8493
  exprId = abortIdsByExpression.size;
8490
8494
  abortIdsByExpression.set(exprRoot, exprId);
8491
8495
  addStatement("render", section, exprRoot.node.extra?.referencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(importRuntime("$signalReset"), [scopeIdentifier, _marko_compiler.types.numericLiteral(exprId)])), false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/runtime-tags",
3
- "version": "6.1.19",
3
+ "version": "6.1.21",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",