@marko/runtime-tags 6.2.5 → 6.3.1

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
@@ -128,10 +128,7 @@ function normalizeDynamicRenderer(value) {
128
128
  const lowercaseEventHandlerReg = /^on[a-z]/;
129
129
  function assertValidAttrValue(name, value) {
130
130
  if (value && typeof value !== "string" && lowercaseEventHandlerReg.test(name)) throw new Error(`The \`${name}\` attribute must be a string or a falsey value (\`null\`, \`undefined\`, \`false\`, \`0\`, …), but received type "${typeof value}". To attach an event listener, use the \`on${name[2].toUpperCase()}${name.slice(3)}\` event handler instead.`);
131
- if (typeof value === "function") {
132
- if (name === "content" || /^on/i.test(name) || /Change$/.test(name)) return;
133
- throw new Error(`The \`${name}\` attribute cannot be a function.`);
134
- }
131
+ if (typeof value === "function") throw new Error(`The \`${name}\` attribute cannot be a function.${/Change$/.test(name) ? " A change handler is only used when its matching controllable attribute combination applies." : ""}`);
135
132
  const unrenderable = describeUnrenderable(value);
136
133
  if (unrenderable) throw new Error(`The \`${name}\` attribute cannot be ${unrenderable}.`);
137
134
  }
@@ -1362,7 +1359,11 @@ function _lifecycle(scope, thisObj, index = 0) {
1362
1359
  instance.onUpdate?.();
1363
1360
  } else {
1364
1361
  scope[accessor] = thisObj;
1365
- thisObj.onMount?.();
1362
+ {
1363
+ const snapshot = { ...thisObj };
1364
+ Object.assign(thisObj, thisObj.onMount?.());
1365
+ for (const prop in snapshot) if (!Object.is(snapshot[prop], thisObj[prop])) throw new Error(`Tried to overwrite existing property "${prop}" in <lifecycle> onMount.`);
1366
+ }
1366
1367
  $signal(scope, accessor).onabort = () => thisObj.onDestroy?.();
1367
1368
  }
1368
1369
  }
@@ -126,10 +126,7 @@ function normalizeDynamicRenderer(value) {
126
126
  const lowercaseEventHandlerReg = /^on[a-z]/;
127
127
  function assertValidAttrValue(name, value) {
128
128
  if (value && typeof value !== "string" && lowercaseEventHandlerReg.test(name)) throw new Error(`The \`${name}\` attribute must be a string or a falsey value (\`null\`, \`undefined\`, \`false\`, \`0\`, …), but received type "${typeof value}". To attach an event listener, use the \`on${name[2].toUpperCase()}${name.slice(3)}\` event handler instead.`);
129
- if (typeof value === "function") {
130
- if (name === "content" || /^on/i.test(name) || /Change$/.test(name)) return;
131
- throw new Error(`The \`${name}\` attribute cannot be a function.`);
132
- }
129
+ if (typeof value === "function") throw new Error(`The \`${name}\` attribute cannot be a function.${/Change$/.test(name) ? " A change handler is only used when its matching controllable attribute combination applies." : ""}`);
133
130
  const unrenderable = describeUnrenderable(value);
134
131
  if (unrenderable) throw new Error(`The \`${name}\` attribute cannot be ${unrenderable}.`);
135
132
  }
@@ -1360,7 +1357,11 @@ function _lifecycle(scope, thisObj, index = 0) {
1360
1357
  instance.onUpdate?.();
1361
1358
  } else {
1362
1359
  scope[accessor] = thisObj;
1363
- thisObj.onMount?.();
1360
+ {
1361
+ const snapshot = { ...thisObj };
1362
+ Object.assign(thisObj, thisObj.onMount?.());
1363
+ for (const prop in snapshot) if (!Object.is(snapshot[prop], thisObj[prop])) throw new Error(`Tried to overwrite existing property "${prop}" in <lifecycle> onMount.`);
1364
+ }
1364
1365
  $signal(scope, accessor).onabort = () => thisObj.onDestroy?.();
1365
1366
  }
1366
1367
  }
@@ -127,10 +127,7 @@ function normalizeDynamicRenderer(value) {
127
127
  const lowercaseEventHandlerReg = /^on[a-z]/;
128
128
  function assertValidAttrValue(name, value) {
129
129
  if (value && typeof value !== "string" && lowercaseEventHandlerReg.test(name)) throw new Error(`The \`${name}\` attribute must be a string or a falsey value (\`null\`, \`undefined\`, \`false\`, \`0\`, …), but received type "${typeof value}". To attach an event listener, use the \`on${name[2].toUpperCase()}${name.slice(3)}\` event handler instead.`);
130
- if (typeof value === "function") {
131
- if (name === "content" || /^on/i.test(name) || /Change$/.test(name)) return;
132
- throw new Error(`The \`${name}\` attribute cannot be a function.`);
133
- }
130
+ if (typeof value === "function") throw new Error(`The \`${name}\` attribute cannot be a function.${/Change$/.test(name) ? " A change handler is only used when its matching controllable attribute combination applies." : ""}`);
134
131
  const unrenderable = describeUnrenderable(value);
135
132
  if (unrenderable) throw new Error(`The \`${name}\` attribute cannot be ${unrenderable}.`);
136
133
  }
@@ -822,7 +819,7 @@ function writeObject(state, val, parent, accessor) {
822
819
  return writeReferenceOr(state, writeUnknownObject, val, parent, accessor);
823
820
  }
824
821
  function writeUnknownObject(state, val, ref) {
825
- switch (val.constructor) {
822
+ switch (Object.getPrototypeOf(val)?.constructor) {
826
823
  case void 0: return writeNullObject(state, val, ref);
827
824
  case Object: return writePlainObject(state, val, ref);
828
825
  case Array: return writeArray(state, val, ref);
@@ -1024,15 +1021,15 @@ function writeWeakMap(state) {
1024
1021
  function writeError(state, val, ref) {
1025
1022
  const result = "new " + val.constructor.name + "(" + quote(val.message + "", 0);
1026
1023
  if (val.cause !== void 0) {
1027
- state.buf.push(result + ",{cause:");
1028
- writeProp(state, val.cause, ref, "cause");
1029
- state.buf.push("})");
1024
+ const pos = state.buf.push(result + ",{cause:") - 1;
1025
+ if (writeProp(state, val.cause, ref, "cause")) state.buf.push("})");
1026
+ else state.buf[pos] = state.buf[pos].slice(0, -8) + ")";
1030
1027
  } else state.buf.push(result + ")");
1031
1028
  return true;
1032
1029
  }
1033
1030
  function writeAggregateError(state, val, ref) {
1034
1031
  state.buf.push("new AggregateError(");
1035
- writeProp(state, val.errors, ref, "errors");
1032
+ if (!writeProp(state, val.errors, ref, "errors")) state.buf.push("[]");
1036
1033
  if (val.message) state.buf.push("," + quote(val.message + "", 0) + ")");
1037
1034
  else state.buf.push(")");
1038
1035
  return true;
@@ -1326,34 +1323,49 @@ function toAccess(accessor) {
1326
1323
  const start = accessor[0];
1327
1324
  return start === "[" ? accessor : start === "\"" || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
1328
1325
  }
1326
+ const unsafeQuoteReg = /["\\<\n\r\u2028\u2029\0\ud800-\udfff]/u;
1329
1327
  function quote(str, startPos) {
1328
+ if (!unsafeQuoteReg.test(str)) return "\"" + str + "\"";
1330
1329
  let result = "";
1331
1330
  let lastPos = 0;
1332
1331
  for (let i = startPos; i < str.length; i++) {
1333
1332
  let replacement;
1334
- switch (str[i]) {
1335
- case "\"":
1333
+ const code = str.charCodeAt(i);
1334
+ switch (code) {
1335
+ case 34:
1336
1336
  replacement = "\\\"";
1337
1337
  break;
1338
- case "\\":
1338
+ case 92:
1339
1339
  replacement = "\\\\";
1340
1340
  break;
1341
- case "<":
1341
+ case 60:
1342
1342
  replacement = "\\x3C";
1343
1343
  break;
1344
- case "\n":
1344
+ case 10:
1345
1345
  replacement = "\\n";
1346
1346
  break;
1347
- case "\r":
1347
+ case 13:
1348
1348
  replacement = "\\r";
1349
1349
  break;
1350
- case "\u2028":
1350
+ case 8232:
1351
1351
  replacement = "\\u2028";
1352
1352
  break;
1353
- case "\u2029":
1353
+ case 8233:
1354
1354
  replacement = "\\u2029";
1355
1355
  break;
1356
- default: continue;
1356
+ case 0:
1357
+ replacement = "\\x00";
1358
+ break;
1359
+ default:
1360
+ if (code < 55296 || code > 57343) continue;
1361
+ if (code < 56320) {
1362
+ const next = str.charCodeAt(i + 1);
1363
+ if (next >= 56320 && next <= 57343) {
1364
+ i++;
1365
+ continue;
1366
+ }
1367
+ }
1368
+ replacement = "\\u" + code.toString(16);
1357
1369
  }
1358
1370
  result += str.slice(lastPos, i) + replacement;
1359
1371
  lastPos = i + 1;
@@ -1920,7 +1932,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
1920
1932
  $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
1921
1933
  } else withIsAsync(content, value);
1922
1934
  });
1923
- boundary.endAsync(chunk);
1935
+ boundary.endAsync();
1924
1936
  }
1925
1937
  }
1926
1938
  }, (err) => {
@@ -1962,7 +1974,7 @@ function tryCatch(content, catchContent) {
1962
1974
  const chunk = $chunk;
1963
1975
  const { boundary } = chunk;
1964
1976
  const { state } = boundary;
1965
- const catchBoundary = new Boundary(state);
1977
+ const catchBoundary = new Boundary(state, void 0, boundary);
1966
1978
  const body = chunk.fork(catchBoundary, null);
1967
1979
  const bodyEnd = body.render(content);
1968
1980
  if (catchBoundary.signal.aborted) {
@@ -2076,19 +2088,21 @@ var State = class {
2076
2088
  };
2077
2089
  var Boundary = class extends AbortController {
2078
2090
  state;
2091
+ parent;
2079
2092
  onNext = NOOP$2;
2080
2093
  count = 0;
2081
- constructor(state, parent) {
2094
+ constructor(state, signal, parent) {
2082
2095
  super();
2083
2096
  this.state = state;
2097
+ this.parent = parent;
2084
2098
  this.signal.addEventListener("abort", () => {
2085
2099
  this.count = 0;
2086
2100
  this.state = new State(this.state.$global);
2087
2101
  this.onNext();
2088
2102
  });
2089
- if (parent) if (parent.aborted) this.abort(parent.reason);
2090
- else parent.addEventListener("abort", () => {
2091
- this.abort(parent.reason);
2103
+ if (signal) if (signal.aborted) this.abort(signal.reason);
2104
+ else signal.addEventListener("abort", () => {
2105
+ this.abort(signal.reason);
2092
2106
  });
2093
2107
  }
2094
2108
  flush() {
@@ -2098,10 +2112,9 @@ var Boundary = class extends AbortController {
2098
2112
  startAsync() {
2099
2113
  if (!this.signal.aborted) this.count++;
2100
2114
  }
2101
- endAsync(chunk) {
2115
+ endAsync() {
2102
2116
  if (!this.signal.aborted && this.count) {
2103
2117
  this.count--;
2104
- if (chunk?.reorderId) this.state.reorder(chunk);
2105
2118
  this.onNext();
2106
2119
  }
2107
2120
  }
@@ -2288,12 +2301,22 @@ var Chunk = class Chunk {
2288
2301
  scripts = concatScripts(scripts, runtimePrefix + ".r=[" + state.resumes + "]");
2289
2302
  }
2290
2303
  if (state.writeReorders) {
2291
- needsWalk = true;
2292
- if (!state.hasReorderRuntime) {
2293
- state.hasReorderRuntime = true;
2294
- scripts = concatScripts(scripts, REORDER_RUNTIME_CODE + "(" + runtimePrefix + ")");
2295
- }
2304
+ let carried = null;
2296
2305
  for (const reorderedChunk of state.writeReorders) {
2306
+ if (reorderedChunk.async && reorderedChunk.consumed) {
2307
+ let aborted = reorderedChunk.boundary;
2308
+ while (aborted && !aborted.signal.aborted) aborted = aborted.parent;
2309
+ if (!aborted) {
2310
+ (carried ||= []).push(reorderedChunk);
2311
+ continue;
2312
+ }
2313
+ reorderedChunk.async = false;
2314
+ }
2315
+ needsWalk = true;
2316
+ if (!state.hasReorderRuntime) {
2317
+ state.hasReorderRuntime = true;
2318
+ scripts = concatScripts(scripts, REORDER_RUNTIME_CODE + "(" + runtimePrefix + ")");
2319
+ }
2297
2320
  const { reorderId } = reorderedChunk;
2298
2321
  const readyReservations = [];
2299
2322
  let reorderHTML = "";
@@ -2312,6 +2335,7 @@ var Chunk = class Chunk {
2312
2335
  reorderScripts = concatScripts(reorderScripts, concatScripts(readyResumeScripts, cur.scripts));
2313
2336
  if (cur.async) {
2314
2337
  reorderHTML += state.mark("#", cur.reorderId = state.nextReorderId());
2338
+ state.reorder(cur);
2315
2339
  cur.html = cur.effects = cur.scripts = cur.lastEffect = "";
2316
2340
  cur.next = null;
2317
2341
  }
@@ -2329,7 +2353,7 @@ var Chunk = class Chunk {
2329
2353
  scripts = concatScripts(scripts, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}");
2330
2354
  html += "<t hidden " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
2331
2355
  }
2332
- state.writeReorders = null;
2356
+ state.writeReorders = carried;
2333
2357
  }
2334
2358
  if (needsWalk) scripts = concatScripts(scripts, runtimePrefix + ".w()");
2335
2359
  this.html = html;
@@ -2656,15 +2680,12 @@ function nonVoidAttr(name, value) {
2656
2680
  case "string": return " " + name + attrAssignment(value);
2657
2681
  case "boolean": return " " + name;
2658
2682
  case "number": return " " + name + "=" + value;
2659
- case "object":
2660
- if (value instanceof RegExp) return " " + name + attrAssignment(value.source);
2661
- break;
2662
2683
  }
2663
2684
  return " " + name + attrAssignment(value + "");
2664
2685
  }
2665
- const singleQuoteAttrReplacements = /'|&(?=#?\w+;)/g;
2666
- const doubleQuoteAttrReplacements = /"|&(?=#?\w+;)/g;
2667
- const needsQuotedAttr = /["'>\s]|&#?\w+;|\/$/g;
2686
+ const singleQuoteAttrReplacements = /'|&(?=[#a-zA-Z])/g;
2687
+ const doubleQuoteAttrReplacements = /"|&(?=[#a-zA-Z])/g;
2688
+ const needsQuotedAttr = /["'>\s]|&[#a-zA-Z]|\/$/g;
2668
2689
  function attrAssignment(value) {
2669
2690
  return value ? needsQuotedAttr.test(value) ? value[needsQuotedAttr.lastIndex - 1] === (needsQuotedAttr.lastIndex = 0, "\"") ? "='" + escapeSingleQuotedAttrValue(value) + "'" : "=\"" + escapeDoubleQuotedAttrValue(value) + "\"" : "=" + value : "";
2670
2691
  }
@@ -125,10 +125,7 @@ function normalizeDynamicRenderer(value) {
125
125
  const lowercaseEventHandlerReg = /^on[a-z]/;
126
126
  function assertValidAttrValue(name, value) {
127
127
  if (value && typeof value !== "string" && lowercaseEventHandlerReg.test(name)) throw new Error(`The \`${name}\` attribute must be a string or a falsey value (\`null\`, \`undefined\`, \`false\`, \`0\`, …), but received type "${typeof value}". To attach an event listener, use the \`on${name[2].toUpperCase()}${name.slice(3)}\` event handler instead.`);
128
- if (typeof value === "function") {
129
- if (name === "content" || /^on/i.test(name) || /Change$/.test(name)) return;
130
- throw new Error(`The \`${name}\` attribute cannot be a function.`);
131
- }
128
+ if (typeof value === "function") throw new Error(`The \`${name}\` attribute cannot be a function.${/Change$/.test(name) ? " A change handler is only used when its matching controllable attribute combination applies." : ""}`);
132
129
  const unrenderable = describeUnrenderable(value);
133
130
  if (unrenderable) throw new Error(`The \`${name}\` attribute cannot be ${unrenderable}.`);
134
131
  }
@@ -820,7 +817,7 @@ function writeObject(state, val, parent, accessor) {
820
817
  return writeReferenceOr(state, writeUnknownObject, val, parent, accessor);
821
818
  }
822
819
  function writeUnknownObject(state, val, ref) {
823
- switch (val.constructor) {
820
+ switch (Object.getPrototypeOf(val)?.constructor) {
824
821
  case void 0: return writeNullObject(state, val, ref);
825
822
  case Object: return writePlainObject(state, val, ref);
826
823
  case Array: return writeArray(state, val, ref);
@@ -1022,15 +1019,15 @@ function writeWeakMap(state) {
1022
1019
  function writeError(state, val, ref) {
1023
1020
  const result = "new " + val.constructor.name + "(" + quote(val.message + "", 0);
1024
1021
  if (val.cause !== void 0) {
1025
- state.buf.push(result + ",{cause:");
1026
- writeProp(state, val.cause, ref, "cause");
1027
- state.buf.push("})");
1022
+ const pos = state.buf.push(result + ",{cause:") - 1;
1023
+ if (writeProp(state, val.cause, ref, "cause")) state.buf.push("})");
1024
+ else state.buf[pos] = state.buf[pos].slice(0, -8) + ")";
1028
1025
  } else state.buf.push(result + ")");
1029
1026
  return true;
1030
1027
  }
1031
1028
  function writeAggregateError(state, val, ref) {
1032
1029
  state.buf.push("new AggregateError(");
1033
- writeProp(state, val.errors, ref, "errors");
1030
+ if (!writeProp(state, val.errors, ref, "errors")) state.buf.push("[]");
1034
1031
  if (val.message) state.buf.push("," + quote(val.message + "", 0) + ")");
1035
1032
  else state.buf.push(")");
1036
1033
  return true;
@@ -1324,34 +1321,49 @@ function toAccess(accessor) {
1324
1321
  const start = accessor[0];
1325
1322
  return start === "[" ? accessor : start === "\"" || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
1326
1323
  }
1324
+ const unsafeQuoteReg = /["\\<\n\r\u2028\u2029\0\ud800-\udfff]/u;
1327
1325
  function quote(str, startPos) {
1326
+ if (!unsafeQuoteReg.test(str)) return "\"" + str + "\"";
1328
1327
  let result = "";
1329
1328
  let lastPos = 0;
1330
1329
  for (let i = startPos; i < str.length; i++) {
1331
1330
  let replacement;
1332
- switch (str[i]) {
1333
- case "\"":
1331
+ const code = str.charCodeAt(i);
1332
+ switch (code) {
1333
+ case 34:
1334
1334
  replacement = "\\\"";
1335
1335
  break;
1336
- case "\\":
1336
+ case 92:
1337
1337
  replacement = "\\\\";
1338
1338
  break;
1339
- case "<":
1339
+ case 60:
1340
1340
  replacement = "\\x3C";
1341
1341
  break;
1342
- case "\n":
1342
+ case 10:
1343
1343
  replacement = "\\n";
1344
1344
  break;
1345
- case "\r":
1345
+ case 13:
1346
1346
  replacement = "\\r";
1347
1347
  break;
1348
- case "\u2028":
1348
+ case 8232:
1349
1349
  replacement = "\\u2028";
1350
1350
  break;
1351
- case "\u2029":
1351
+ case 8233:
1352
1352
  replacement = "\\u2029";
1353
1353
  break;
1354
- default: continue;
1354
+ case 0:
1355
+ replacement = "\\x00";
1356
+ break;
1357
+ default:
1358
+ if (code < 55296 || code > 57343) continue;
1359
+ if (code < 56320) {
1360
+ const next = str.charCodeAt(i + 1);
1361
+ if (next >= 56320 && next <= 57343) {
1362
+ i++;
1363
+ continue;
1364
+ }
1365
+ }
1366
+ replacement = "\\u" + code.toString(16);
1355
1367
  }
1356
1368
  result += str.slice(lastPos, i) + replacement;
1357
1369
  lastPos = i + 1;
@@ -1918,7 +1930,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
1918
1930
  $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
1919
1931
  } else withIsAsync(content, value);
1920
1932
  });
1921
- boundary.endAsync(chunk);
1933
+ boundary.endAsync();
1922
1934
  }
1923
1935
  }
1924
1936
  }, (err) => {
@@ -1960,7 +1972,7 @@ function tryCatch(content, catchContent) {
1960
1972
  const chunk = $chunk;
1961
1973
  const { boundary } = chunk;
1962
1974
  const { state } = boundary;
1963
- const catchBoundary = new Boundary(state);
1975
+ const catchBoundary = new Boundary(state, void 0, boundary);
1964
1976
  const body = chunk.fork(catchBoundary, null);
1965
1977
  const bodyEnd = body.render(content);
1966
1978
  if (catchBoundary.signal.aborted) {
@@ -2074,19 +2086,21 @@ var State = class {
2074
2086
  };
2075
2087
  var Boundary = class extends AbortController {
2076
2088
  state;
2089
+ parent;
2077
2090
  onNext = NOOP$2;
2078
2091
  count = 0;
2079
- constructor(state, parent) {
2092
+ constructor(state, signal, parent) {
2080
2093
  super();
2081
2094
  this.state = state;
2095
+ this.parent = parent;
2082
2096
  this.signal.addEventListener("abort", () => {
2083
2097
  this.count = 0;
2084
2098
  this.state = new State(this.state.$global);
2085
2099
  this.onNext();
2086
2100
  });
2087
- if (parent) if (parent.aborted) this.abort(parent.reason);
2088
- else parent.addEventListener("abort", () => {
2089
- this.abort(parent.reason);
2101
+ if (signal) if (signal.aborted) this.abort(signal.reason);
2102
+ else signal.addEventListener("abort", () => {
2103
+ this.abort(signal.reason);
2090
2104
  });
2091
2105
  }
2092
2106
  flush() {
@@ -2096,10 +2110,9 @@ var Boundary = class extends AbortController {
2096
2110
  startAsync() {
2097
2111
  if (!this.signal.aborted) this.count++;
2098
2112
  }
2099
- endAsync(chunk) {
2113
+ endAsync() {
2100
2114
  if (!this.signal.aborted && this.count) {
2101
2115
  this.count--;
2102
- if (chunk?.reorderId) this.state.reorder(chunk);
2103
2116
  this.onNext();
2104
2117
  }
2105
2118
  }
@@ -2286,12 +2299,22 @@ var Chunk = class Chunk {
2286
2299
  scripts = concatScripts(scripts, runtimePrefix + ".r=[" + state.resumes + "]");
2287
2300
  }
2288
2301
  if (state.writeReorders) {
2289
- needsWalk = true;
2290
- if (!state.hasReorderRuntime) {
2291
- state.hasReorderRuntime = true;
2292
- scripts = concatScripts(scripts, REORDER_RUNTIME_CODE + "(" + runtimePrefix + ")");
2293
- }
2302
+ let carried = null;
2294
2303
  for (const reorderedChunk of state.writeReorders) {
2304
+ if (reorderedChunk.async && reorderedChunk.consumed) {
2305
+ let aborted = reorderedChunk.boundary;
2306
+ while (aborted && !aborted.signal.aborted) aborted = aborted.parent;
2307
+ if (!aborted) {
2308
+ (carried ||= []).push(reorderedChunk);
2309
+ continue;
2310
+ }
2311
+ reorderedChunk.async = false;
2312
+ }
2313
+ needsWalk = true;
2314
+ if (!state.hasReorderRuntime) {
2315
+ state.hasReorderRuntime = true;
2316
+ scripts = concatScripts(scripts, REORDER_RUNTIME_CODE + "(" + runtimePrefix + ")");
2317
+ }
2295
2318
  const { reorderId } = reorderedChunk;
2296
2319
  const readyReservations = [];
2297
2320
  let reorderHTML = "";
@@ -2310,6 +2333,7 @@ var Chunk = class Chunk {
2310
2333
  reorderScripts = concatScripts(reorderScripts, concatScripts(readyResumeScripts, cur.scripts));
2311
2334
  if (cur.async) {
2312
2335
  reorderHTML += state.mark("#", cur.reorderId = state.nextReorderId());
2336
+ state.reorder(cur);
2313
2337
  cur.html = cur.effects = cur.scripts = cur.lastEffect = "";
2314
2338
  cur.next = null;
2315
2339
  }
@@ -2327,7 +2351,7 @@ var Chunk = class Chunk {
2327
2351
  scripts = concatScripts(scripts, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}");
2328
2352
  html += "<t hidden " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
2329
2353
  }
2330
- state.writeReorders = null;
2354
+ state.writeReorders = carried;
2331
2355
  }
2332
2356
  if (needsWalk) scripts = concatScripts(scripts, runtimePrefix + ".w()");
2333
2357
  this.html = html;
@@ -2654,15 +2678,12 @@ function nonVoidAttr(name, value) {
2654
2678
  case "string": return " " + name + attrAssignment(value);
2655
2679
  case "boolean": return " " + name;
2656
2680
  case "number": return " " + name + "=" + value;
2657
- case "object":
2658
- if (value instanceof RegExp) return " " + name + attrAssignment(value.source);
2659
- break;
2660
2681
  }
2661
2682
  return " " + name + attrAssignment(value + "");
2662
2683
  }
2663
- const singleQuoteAttrReplacements = /'|&(?=#?\w+;)/g;
2664
- const doubleQuoteAttrReplacements = /"|&(?=#?\w+;)/g;
2665
- const needsQuotedAttr = /["'>\s]|&#?\w+;|\/$/g;
2684
+ const singleQuoteAttrReplacements = /'|&(?=[#a-zA-Z])/g;
2685
+ const doubleQuoteAttrReplacements = /"|&(?=[#a-zA-Z])/g;
2686
+ const needsQuotedAttr = /["'>\s]|&[#a-zA-Z]|\/$/g;
2666
2687
  function attrAssignment(value) {
2667
2688
  return value ? needsQuotedAttr.test(value) ? value[needsQuotedAttr.lastIndex - 1] === (needsQuotedAttr.lastIndex = 0, "\"") ? "='" + escapeSingleQuotedAttrValue(value) + "'" : "=\"" + escapeDoubleQuotedAttrValue(value) + "\"" : "=" + value : "";
2668
2689
  }
package/dist/dom/dom.d.ts CHANGED
@@ -21,7 +21,7 @@ export declare function _attrs_script(scope: Scope, nodeAccessor: Accessor): voi
21
21
  export declare function _html(scope: Scope, value: unknown, accessor: Accessor): void;
22
22
  export declare function normalizeAttrValue(value: unknown): string | undefined;
23
23
  export declare function _lifecycle(scope: Scope, thisObj: Record<string, unknown> & {
24
- onMount?: (this: unknown) => void;
24
+ onMount?: (this: unknown) => Record<string, unknown> | void;
25
25
  onUpdate?: (this: unknown) => void;
26
26
  onDestroy?: (this: unknown) => void;
27
27
  }, index?: number): void;
package/dist/dom.js CHANGED
@@ -289,7 +289,7 @@ function _let(id, fn) {
289
289
  return (scope, value) => (rendering ? scope.H === runId && (scope[valueAccessor] = value, fn?.(scope)) : (scope[valueAccessor] !== value || !(valueAccessor in scope)) && (scope[valueAccessor] = value, fn) && (schedule(), queueRender(scope, fn, id)), value);
290
290
  }
291
291
  function _let_change(id, fn) {
292
- let valueAccessor = decodeAccessor(id), valueChangeAccessor = "M" + valueAccessor, base = _let(id, fn);
292
+ let valueAccessor = decodeAccessor(id), valueChangeAccessor = decodeAccessor(id + 1), base = _let(id, fn);
293
293
  return (scope, value, valueChange) => (rendering ? (scope[valueChangeAccessor] = valueChange) && (scope[valueAccessor] !== value || !(valueAccessor in scope)) ? (scope[valueAccessor] = value, fn?.(scope)) : base(scope, value) : scope[valueChangeAccessor] ? scope[valueChangeAccessor](value) : base(scope, value), value);
294
294
  }
295
295
  function _const(valueAccessor, fn) {
@@ -366,7 +366,7 @@ function _closure_get(valueAccessor, fn, getOwnerScope, resumeId) {
366
366
  let closureSignal = ((scope) => {
367
367
  scope[closureSignal.b] = closureSignal.c, fn(scope), subscribeToScopeSet(getOwnerScope ? getOwnerScope(scope) : scope._, closureSignal.a, scope);
368
368
  });
369
- return closureSignal.a = "B" + valueAccessor, closureSignal.b = "C" + valueAccessor, resumeId && _resume(resumeId, closureSignal), closureSignal;
369
+ return closureSignal.a = valueAccessor, closureSignal.b = "C" + valueAccessor, resumeId && _resume(resumeId, closureSignal), closureSignal;
370
370
  }
371
371
  function _child_setup(setup) {
372
372
  return setup._ = (scope, owner) => {
@@ -894,7 +894,7 @@ function normalizeAttrValue(value) {
894
894
  }
895
895
  function _lifecycle(scope, thisObj, index = 0) {
896
896
  let accessor = "K" + index, instance = scope[accessor];
897
- instance ? (Object.assign(instance, thisObj), instance.onUpdate?.()) : (scope[accessor] = thisObj, thisObj.onMount?.(), $signal(scope, accessor).onabort = () => thisObj.onDestroy?.());
897
+ instance ? (Object.assign(instance, thisObj), instance.onUpdate?.()) : (scope[accessor] = thisObj, Object.assign(thisObj, thisObj.onMount?.()), $signal(scope, accessor).onabort = () => thisObj.onDestroy?.());
898
898
  }
899
899
  function removeChildNodes(startNode, endNode) {
900
900
  let stop = endNode.nextSibling;
package/dist/dom.mjs CHANGED
@@ -288,7 +288,7 @@ function _let(id, fn) {
288
288
  return (scope, value) => (rendering ? scope.H === runId && (scope[valueAccessor] = value, fn?.(scope)) : (scope[valueAccessor] !== value || !(valueAccessor in scope)) && (scope[valueAccessor] = value, fn) && (schedule(), queueRender(scope, fn, id)), value);
289
289
  }
290
290
  function _let_change(id, fn) {
291
- let valueAccessor = decodeAccessor(id), valueChangeAccessor = "M" + valueAccessor, base = _let(id, fn);
291
+ let valueAccessor = decodeAccessor(id), valueChangeAccessor = decodeAccessor(id + 1), base = _let(id, fn);
292
292
  return (scope, value, valueChange) => (rendering ? (scope[valueChangeAccessor] = valueChange) && (scope[valueAccessor] !== value || !(valueAccessor in scope)) ? (scope[valueAccessor] = value, fn?.(scope)) : base(scope, value) : scope[valueChangeAccessor] ? scope[valueChangeAccessor](value) : base(scope, value), value);
293
293
  }
294
294
  function _const(valueAccessor, fn) {
@@ -365,7 +365,7 @@ function _closure_get(valueAccessor, fn, getOwnerScope, resumeId) {
365
365
  let closureSignal = ((scope) => {
366
366
  scope[closureSignal.b] = closureSignal.c, fn(scope), subscribeToScopeSet(getOwnerScope ? getOwnerScope(scope) : scope._, closureSignal.a, scope);
367
367
  });
368
- return closureSignal.a = "B" + valueAccessor, closureSignal.b = "C" + valueAccessor, resumeId && _resume(resumeId, closureSignal), closureSignal;
368
+ return closureSignal.a = valueAccessor, closureSignal.b = "C" + valueAccessor, resumeId && _resume(resumeId, closureSignal), closureSignal;
369
369
  }
370
370
  function _child_setup(setup) {
371
371
  return setup._ = (scope, owner) => {
@@ -893,7 +893,7 @@ function normalizeAttrValue(value) {
893
893
  }
894
894
  function _lifecycle(scope, thisObj, index = 0) {
895
895
  let accessor = "K" + index, instance = scope[accessor];
896
- instance ? (Object.assign(instance, thisObj), instance.onUpdate?.()) : (scope[accessor] = thisObj, thisObj.onMount?.(), $signal(scope, accessor).onabort = () => thisObj.onDestroy?.());
896
+ instance ? (Object.assign(instance, thisObj), instance.onUpdate?.()) : (scope[accessor] = thisObj, Object.assign(thisObj, thisObj.onMount?.()), $signal(scope, accessor).onabort = () => thisObj.onDestroy?.());
897
897
  }
898
898
  function removeChildNodes(startNode, endNode) {
899
899
  let stop = endNode.nextSibling;
@@ -121,12 +121,13 @@ export declare enum FlushStatus {
121
121
  }
122
122
  export declare class Boundary extends AbortController {
123
123
  state: State;
124
+ parent?: Boundary | undefined;
124
125
  onNext: () => void;
125
126
  count: number;
126
- constructor(state: State, parent?: AbortSignal);
127
+ constructor(state: State, signal?: AbortSignal, parent?: Boundary | undefined);
127
128
  flush(): FlushStatus;
128
129
  startAsync(): void;
129
- endAsync(chunk?: Chunk): void;
130
+ endAsync(): void;
130
131
  }
131
132
  export declare class Chunk {
132
133
  boundary: Boundary;