marko 6.3.34 → 6.3.35

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.
Files changed (53) hide show
  1. package/cheatsheet.md +2 -2
  2. package/dist/common/constants/accessor-prefix.d.ts +1 -0
  3. package/dist/common/constants/accessor-prefix.debug.d.ts +1 -0
  4. package/dist/common/errors.d.ts +1 -0
  5. package/dist/common/types.d.ts +10 -0
  6. package/dist/debug/dom/catch.feat.js +1 -1
  7. package/dist/debug/dom/catch.feat.mjs +1 -1
  8. package/dist/debug/dom/controllable-input.feat.js +1 -1
  9. package/dist/debug/dom/controllable-input.feat.mjs +1 -1
  10. package/dist/debug/dom/controllable-open.feat.js +1 -1
  11. package/dist/debug/dom/controllable-open.feat.mjs +1 -1
  12. package/dist/debug/dom/controllable-select.feat.js +1 -1
  13. package/dist/debug/dom/controllable-select.feat.mjs +1 -1
  14. package/dist/debug/dom/controllable-textarea.feat.js +1 -1
  15. package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
  16. package/dist/debug/dom/controllable.feat.js +1 -1
  17. package/dist/debug/dom/controllable.feat.mjs +1 -1
  18. package/dist/debug/{dom-klf8Ec_o.mjs → dom-B57LrRnX.mjs} +34 -16
  19. package/dist/debug/{dom-Bj58jt8y.js → dom-Bt4OoZ-j.js} +34 -16
  20. package/dist/debug/dom.js +1 -1
  21. package/dist/debug/dom.mjs +1 -1
  22. package/dist/debug/html.js +88 -21
  23. package/dist/debug/html.mjs +88 -21
  24. package/dist/dom/catch.feat.js +1 -1
  25. package/dist/dom/catch.feat.mjs +1 -1
  26. package/dist/dom/control-flow.d.ts +1 -0
  27. package/dist/dom/controllable-input.feat.js +1 -1
  28. package/dist/dom/controllable-input.feat.mjs +1 -1
  29. package/dist/dom/controllable-open.feat.js +1 -1
  30. package/dist/dom/controllable-open.feat.mjs +1 -1
  31. package/dist/dom/controllable-select.feat.js +1 -1
  32. package/dist/dom/controllable-select.feat.mjs +1 -1
  33. package/dist/dom/controllable-textarea.feat.js +1 -1
  34. package/dist/dom/controllable-textarea.feat.mjs +1 -1
  35. package/dist/dom/controllable.feat.js +1 -1
  36. package/dist/dom/controllable.feat.mjs +1 -1
  37. package/dist/dom/signals.d.ts +3 -3
  38. package/dist/{dom-6hBvZW7X.mjs → dom-BP2XSglG.mjs} +19 -12
  39. package/dist/{dom-B-XpL2_H.js → dom-BeF9xIzO.js} +19 -12
  40. package/dist/dom.js +1 -1
  41. package/dist/dom.mjs +1 -1
  42. package/dist/html/dynamic-tag.d.ts +1 -1
  43. package/dist/html/serializer.d.ts +9 -1
  44. package/dist/html/template.d.ts +1 -0
  45. package/dist/html/writer.d.ts +1 -0
  46. package/dist/html.js +15 -9
  47. package/dist/html.mjs +15 -9
  48. package/dist/translator/index.js +137 -70
  49. package/dist/translator/util/signals.d.ts +2 -0
  50. package/dist/translator/util/translate-var.d.ts +1 -1
  51. package/dist/translator/visitors/export-declaration.d.ts +8 -0
  52. package/package.json +4 -4
  53. package/tags/let.d.marko +3 -4
package/cheatsheet.md CHANGED
@@ -13,8 +13,8 @@ Marko 6 = HTML superset, not JSX and not Marko 4/5 syntax. `.marko` files are co
13
13
  - remove: `items = items.toSpliced(i, 1)`
14
14
  - update: `items = items.toSpliced(i, 1, { ...item, done: true })`
15
15
  - object: `user = { ...user, name }`
16
- 6. Events: method shorthand `onClick() { ... }` or `onClick=fn`. Handlers receive `(event, element)`; delegation means the element is the second parameter, not `event.currentTarget`: `onSubmit(e) { e.preventDefault(); save() }`, `onClick(e, el) { el.focus() }`. Don't sync input values through `onInput`/`onChange`; that's what the change handlers below are for.
17
- 7. Native inputs are uncontrolled by default: `value=` only sets the initial value. Adding the matching `*Change` handler is what makes them controlled: `valueChange` on `<input>`/`<textarea>`/`<select>`, `checkedChange` on checkboxes/radios, `openChange` on `<details>`/`<dialog>`. `value:=text` is the shorthand for `value=text valueChange(v) { text = v }`. (`<textarea value:=text/>`: value attribute, not body.)
16
+ 6. Events: method shorthand `onClick() { ... }` or `onClick=fn`. Handlers receive `(event, element)`; delegation means the element is the second parameter, not `event.currentTarget`: `onSubmit(e) { e.preventDefault(); save() }`, `onClick(e, el) { el.focus() }`. Don't sync input values through `onInput`/`onChange`; that's what the change handlers below are for. Prefix with `async` to `await` in the body: `async onClick() { await save() }`.
17
+ 7. Native inputs are uncontrolled by default: `value=` sets the default value — later writes update what `form.reset()` restores, never a dirty field's display. Adding the matching `*Change` handler is what makes them controlled: `valueChange` on `<input>`/`<textarea>`/`<select>`, `checkedChange` on checkboxes/radios, `openChange` on `<details>`/`<dialog>`. `value:=text` is the shorthand for `value=text valueChange(v) { text = v }`. (`<textarea value:=text/>`: value attribute, not body.)
18
18
  8. Transform in the handler when needed; number inputs give strings: `<input type="number" value=n valueChange(v) { n = +v }>`, or `value:parseFloat:=n`.
19
19
  9. Radio/checkbox groups: `checkedValue:=picked` on each input (shared var, distinct `value=`); the match is checked; array var for multi-checkbox. Dropdown: `<select value:=picked>`.
20
20
  10. Module-level values and helpers need `static`: `static const LIMIT = 10`, `static function fmt(n) {…}`. Without it `function fmt(n) {` parses as a tag: ``Unable to find entry point for custom tag `<function>` ``, an error that never says `static`. Prefer it to `<const>` for anything that never changes: `<const/LIMIT=10>` emits a per-instance signal plus a `$setup` call.
@@ -8,6 +8,7 @@ export declare const ControlledType = "F";
8
8
  export declare const ControlledValue = "G";
9
9
  export declare const DynamicHTMLLastChild = "H";
10
10
  export declare const EventAttributes = "I";
11
+ export declare const IdFallback = "J";
11
12
  export declare const KeyedScopes = "O";
12
13
  export declare const Lifecycle = "K";
13
14
  export declare const Promise = "L";
@@ -8,6 +8,7 @@ export declare const ControlledType = "ControlledType:";
8
8
  export declare const ControlledValue = "ControlledValue:";
9
9
  export declare const DynamicHTMLLastChild = "DynamicHTMLLastChild:";
10
10
  export declare const EventAttributes = "EventAttributes:";
11
+ export declare const IdFallback = "IdFallback:";
11
12
  export declare const KeyedScopes = "KeyedScopes:";
12
13
  export declare const Lifecycle = "Lifecycle:";
13
14
  export declare const Promise = "Promise:";
@@ -9,6 +9,7 @@ export declare function _el_read_error(): void;
9
9
  export declare function _hoist_read_error(): void;
10
10
  export declare function _assert_hoist(value: unknown): void;
11
11
  export declare function assertExclusiveAttrs(attrs: Record<string, unknown> | undefined, onError?: typeof throwErr): void;
12
+ export declare function assertNoValueBindingOnCheckable(type: unknown, valueChange: unknown): void;
12
13
  export declare function assertHandlerIsFunction(name: string, value: unknown): void;
13
14
  export declare function assertValidTagName(tagName: string): void;
14
15
  declare function throwErr(msg: string): void;
@@ -73,6 +73,16 @@ export interface MountedTemplate {
73
73
  }
74
74
  export type RenderedTemplate = PromiseLike<string> & AsyncIterable<string> & {
75
75
  toReadable(): ReadableStream<Uint8Array<ArrayBufferLike>>;
76
+ pipe(stream: {
77
+ write(chunk: string): unknown;
78
+ end(): unknown;
79
+ flush?(): void;
80
+ destroy?(): void;
81
+ emit?(name: PropertyKey, ...args: unknown[]): unknown;
82
+ }): void;
83
+ toString(): string;
84
+ catch<T = never>(onrejected?: ((reason: unknown) => T | PromiseLike<T>) | undefined | null): Promise<string | T>;
85
+ finally(onfinally?: (() => void) | undefined | null): Promise<string>;
76
86
  };
77
87
  type ControlledType = ControlledType.Value;
78
88
  export { ControlledType };
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const require_control_flow = require("../dom-Bj58jt8y.js");
2
+ const require_control_flow = require("../dom-Bt4OoZ-j.js");
3
3
  //#region src/dom/catch.feat.ts
4
4
  const handlePendingTry = (fn, scope, branch) => {
5
5
  while (branch) {
@@ -1,4 +1,4 @@
1
- import { Cn as PendingRenders, Jt as caughtError, Sn as PendingEffects, Xt as placeholderShown, Yt as installCatch, gn as ClosestBranch, h as renderCatch, mn as Scope, pn as Pending, xn as ParentBranch } from "../dom-klf8Ec_o.mjs";
1
+ import { Cn as PendingRenders, Jt as caughtError, Sn as PendingEffects, Xt as placeholderShown, Yt as installCatch, gn as ClosestBranch, h as renderCatch, mn as Scope, pn as Pending, xn as ParentBranch } from "../dom-B57LrRnX.mjs";
2
2
  //#region src/dom/catch.feat.ts
3
3
  const handlePendingTry = (fn, scope, branch) => {
4
4
  while (branch) {
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const require_control_flow = require("../dom-Bj58jt8y.js");
2
+ const require_control_flow = require("../dom-Bt4OoZ-j.js");
3
3
  //#region src/dom/controllable-input.feat.ts
4
4
  require_control_flow.controllableScripts[0] = require_control_flow._attr_input_checked_script;
5
5
  require_control_flow.controllableScripts[1] = require_control_flow._attr_input_checkedValue_script;
@@ -1,4 +1,4 @@
1
- import { R as controllableScripts, S as _attr_input_checkedValue_script, k as _attr_input_value_script, w as _attr_input_checked_script } from "../dom-klf8Ec_o.mjs";
1
+ import { R as controllableScripts, S as _attr_input_checkedValue_script, k as _attr_input_value_script, w as _attr_input_checked_script } from "../dom-B57LrRnX.mjs";
2
2
  //#region src/dom/controllable-input.feat.ts
3
3
  controllableScripts[0] = _attr_input_checked_script;
4
4
  controllableScripts[1] = _attr_input_checkedValue_script;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const require_control_flow = require("../dom-Bj58jt8y.js");
2
+ const require_control_flow = require("../dom-Bt4OoZ-j.js");
3
3
  //#region src/dom/controllable-open.feat.ts
4
4
  require_control_flow.controllableScripts[4] = require_control_flow._attr_details_or_dialog_open_script;
5
5
  //#endregion
@@ -1,4 +1,4 @@
1
- import { R as controllableScripts, v as _attr_details_or_dialog_open_script } from "../dom-klf8Ec_o.mjs";
1
+ import { R as controllableScripts, v as _attr_details_or_dialog_open_script } from "../dom-B57LrRnX.mjs";
2
2
  //#region src/dom/controllable-open.feat.ts
3
3
  controllableScripts[4] = _attr_details_or_dialog_open_script;
4
4
  //#endregion
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const require_control_flow = require("../dom-Bj58jt8y.js");
2
+ const require_control_flow = require("../dom-Bt4OoZ-j.js");
3
3
  //#region src/dom/controllable-select.feat.ts
4
4
  require_control_flow.controllableScripts[3] = require_control_flow._attr_select_value_script;
5
5
  //#endregion
@@ -1,4 +1,4 @@
1
- import { M as _attr_select_value_script, R as controllableScripts } from "../dom-klf8Ec_o.mjs";
1
+ import { M as _attr_select_value_script, R as controllableScripts } from "../dom-B57LrRnX.mjs";
2
2
  //#region src/dom/controllable-select.feat.ts
3
3
  controllableScripts[3] = _attr_select_value_script;
4
4
  //#endregion
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const require_control_flow = require("../dom-Bj58jt8y.js");
2
+ const require_control_flow = require("../dom-Bt4OoZ-j.js");
3
3
  //#region src/dom/controllable-textarea.feat.ts
4
4
  require_control_flow.controllableScripts[2] = require_control_flow._attr_input_value_script;
5
5
  //#endregion
@@ -1,4 +1,4 @@
1
- import { R as controllableScripts, k as _attr_input_value_script } from "../dom-klf8Ec_o.mjs";
1
+ import { R as controllableScripts, k as _attr_input_value_script } from "../dom-B57LrRnX.mjs";
2
2
  //#region src/dom/controllable-textarea.feat.ts
3
3
  controllableScripts[2] = _attr_input_value_script;
4
4
  //#endregion
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const require_control_flow = require("../dom-Bj58jt8y.js");
2
+ const require_control_flow = require("../dom-Bt4OoZ-j.js");
3
3
  require("./controllable-input.feat.js");
4
4
  require("./controllable-open.feat.js");
5
5
  require("./controllable-select.feat.js");
@@ -1,4 +1,4 @@
1
- import { F as _controllable_select, I as _controllable_textarea, L as controllableRenders, N as _controllable_input, P as _controllable_open } from "../dom-klf8Ec_o.mjs";
1
+ import { F as _controllable_select, I as _controllable_textarea, L as controllableRenders, N as _controllable_input, P as _controllable_open } from "../dom-B57LrRnX.mjs";
2
2
  import "./controllable-input.feat.mjs";
3
3
  import "./controllable-open.feat.mjs";
4
4
  import "./controllable-select.feat.mjs";
@@ -253,10 +253,16 @@ function assertExclusiveAttrs(attrs, onError = throwErr) {
253
253
  (exclusiveAttrs ||= []).push("checkedValueChange");
254
254
  if ("checked" in attrs) exclusiveAttrs.push("checked");
255
255
  }
256
- if (attrs.valueChange) (exclusiveAttrs ||= []).push("valueChange");
256
+ if (attrs.valueChange) {
257
+ (exclusiveAttrs ||= []).push("valueChange");
258
+ if ("checked" in attrs && !exclusiveAttrs.includes("checked")) exclusiveAttrs.push("checked");
259
+ }
257
260
  if (exclusiveAttrs && exclusiveAttrs.length > 1) onError(`The attributes ${joinWithAnd(exclusiveAttrs)} are mutually exclusive.`);
258
261
  }
259
262
  }
263
+ function assertNoValueBindingOnCheckable(type, valueChange) {
264
+ if (valueChange && /^(?:button|checkbox|hidden|image|radio|reset|submit)$/i.test(type)) console.error(`\`valueChange\` cannot be used on a \`type="${type}"\` \`<input>\` — user interaction can never change its \`value\`.` + (/^[cr]/i.test(type) ? " Bind `checked` or `checkedValue` instead." : ""));
265
+ }
260
266
  function assertHandlerIsFunction(name, value) {
261
267
  if (value && typeof value !== "function") throw new Error(`The \`${name}\` handler must be a function or a falsey value (\`null\`, \`undefined\`, \`false\`, \`0\`, …), but received type "${typeof value}".`);
262
268
  }
@@ -741,10 +747,16 @@ const _var_change = (scope, value, name = "This") => {
741
747
  scope[TagVariableChange](value);
742
748
  };
743
749
  const tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
744
- function _id({ [Global]: $global }) {
745
- const id = tagIdsByGlobal.get($global) || 0;
746
- tagIdsByGlobal.set($global, id + 1);
747
- return "c" + $global.runtimeId + $global.renderId + id.toString(36);
750
+ function _id(scope, accessor) {
751
+ let id = accessor !== void 0 && scope[accessor];
752
+ if (!id) {
753
+ const $global = scope[Global];
754
+ const n = tagIdsByGlobal.get($global) || 0;
755
+ tagIdsByGlobal.set($global, n + 1);
756
+ id = "c" + $global.runtimeId + $global.renderId + n.toString(36);
757
+ if (accessor !== void 0) scope[accessor] = id;
758
+ }
759
+ return id;
748
760
  }
749
761
  function _script(id, fn) {
750
762
  _resume(id, fn);
@@ -756,19 +768,19 @@ function _el_read(value) {
756
768
  if (rendering) _el_read_error();
757
769
  return value;
758
770
  }
759
- function* traverse(scope, path, i = path.length - 1) {
771
+ function* traverse(scope, path, args, i = path.length - 1) {
760
772
  if (rendering) _hoist_read_error();
761
- if (scope) if (Symbol.iterator in scope) for (const childScope of scope.values()) yield* traverse(childScope, path, i);
773
+ if (scope) if (Symbol.iterator in scope) for (const childScope of scope.values()) yield* traverse(childScope, path, args, i);
762
774
  else {
763
775
  const item = scope[path[i]];
764
- if (i) yield* traverse(item, path, i - 1);
765
- else yield typeof item === "function" ? item() : item;
776
+ if (i) yield* traverse(item, path, args, i - 1);
777
+ else yield typeof item === "function" ? item(...args) : item;
766
778
  }
767
779
  }
768
780
  function _hoist(...path) {
769
781
  return (scope) => {
770
- const fn = () => traverse(scope, path).next().value;
771
- fn[Symbol.iterator] = () => traverse(scope, path);
782
+ const fn = (...args) => traverse(scope, path, args).next().value;
783
+ fn[Symbol.iterator] = () => traverse(scope, path, []);
772
784
  return fn;
773
785
  };
774
786
  }
@@ -1235,7 +1247,7 @@ function attrsInternal(scope, nodeAccessor, nextAttrs, controllable) {
1235
1247
  }
1236
1248
  function _attr_content(scope, nodeAccessor, value) {
1237
1249
  const content = normalizeClientRender(value);
1238
- if (scope["ConditionalRenderer:" + nodeAccessor] !== (scope["ConditionalRenderer:" + nodeAccessor] = content?.["id"])) {
1250
+ if (scope["ConditionalRenderer:" + nodeAccessor] !== (scope["ConditionalRenderer:" + nodeAccessor] = rendererKey(content))) {
1239
1251
  setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch);
1240
1252
  if (content?.["accessor"]) subscribeToScopeSet(content[Owner], content[Accessor], scope[BranchScopes$1 + nodeAccessor]);
1241
1253
  }
@@ -1415,17 +1427,19 @@ function _attr_input_value(scope, nodeAccessor, value, valueChange, setDefault =
1415
1427
  const el = scope[nodeAccessor];
1416
1428
  const normalizedValue = normalizeAttrValue(value) || "";
1417
1429
  assertHandlerIsFunction("valueChange", valueChange);
1430
+ assertNoValueBindingOnCheckable(el.type, valueChange);
1418
1431
  scope[ControlledHandler + nodeAccessor] = valueChange;
1419
1432
  scope[ControlledValue + nodeAccessor] = normalizedValue;
1420
1433
  scope[ControlledType + nodeAccessor] = valueChange ? 2 : 5;
1421
1434
  if (valueChange && scope["#Gen"] < runId) setInputValue(el, normalizedValue);
1422
- else setDefault(scope, nodeAccessor, normalizedValue);
1435
+ else setDefault(scope, nodeAccessor, value);
1423
1436
  }
1424
1437
  function _attr_input_value_attribute_default(scope, nodeAccessor, value) {
1425
1438
  _attr(scope[nodeAccessor], "value", value);
1426
1439
  }
1427
1440
  function _attr_input_value_script(scope, nodeAccessor) {
1428
1441
  const el = scope[nodeAccessor];
1442
+ assertNoValueBindingOnCheckable(el.type, scope[ControlledHandler + nodeAccessor]);
1429
1443
  if (isResuming) scope[ControlledValue + nodeAccessor] = el.defaultValue;
1430
1444
  syncControllableFormInput(el, hasValueChanged, (ev) => {
1431
1445
  const valueChange = scope[ControlledHandler + nodeAccessor];
@@ -1833,6 +1847,9 @@ const _show = /*@__PURE__*/ withBranches((nodeAccessor, startNodeAccessor, endNo
1833
1847
  }
1834
1848
  };
1835
1849
  });
1850
+ function rendererKey(renderer) {
1851
+ return renderer?.["owner"] ? renderer["id"] + " " + renderer[Owner]["#Id"] : renderer?.["id"] || renderer;
1852
+ }
1836
1853
  function patchDynamicTag(fn) {
1837
1854
  _dynamic_tag = fn(_dynamic_tag);
1838
1855
  }
@@ -1841,9 +1858,10 @@ let _dynamic_tag = /*@__PURE__*/ withBranches((nodeAccessor, getContent, getTagV
1841
1858
  const rendererAccessor = ConditionalRenderer + nodeAccessor;
1842
1859
  return (scope, newRenderer, getInput) => {
1843
1860
  const normalizedRenderer = normalizeDynamicRenderer(newRenderer);
1844
- if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.["id"] || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor])) {
1861
+ if (scope[rendererAccessor] !== (scope[rendererAccessor] = rendererKey(normalizedRenderer)) || getContent && !(normalizedRenderer || scope[childScopeAccessor])) {
1845
1862
  setConditionalRenderer(scope, nodeAccessor, normalizedRenderer || (getContent ? getContent(scope) : void 0), createBranchWithTagNameOrRenderer);
1846
- if (getTagVar) scope[childScopeAccessor][TagVariable] = (value) => getTagVar()(scope, value);
1863
+ if (getTagVar) if (scope[childScopeAccessor]) scope[childScopeAccessor][TagVariable] = (value) => getTagVar()(scope, value);
1864
+ else getTagVar()(scope, void 0);
1847
1865
  if (typeof normalizedRenderer === "string") {
1848
1866
  if (getContent) {
1849
1867
  const content = getContent(scope);
@@ -1877,7 +1895,7 @@ const _dynamic_tag_content = /*@__PURE__*/ withBranches((nodeAccessor) => {
1877
1895
  const childScopeAccessor = BranchScopes$1 + nodeAccessor;
1878
1896
  const rendererAccessor = ConditionalRenderer + nodeAccessor;
1879
1897
  return (scope, renderer) => {
1880
- if (scope[rendererAccessor] !== (scope[rendererAccessor] = renderer?.["id"] || renderer)) {
1898
+ if (scope[rendererAccessor] !== (scope[rendererAccessor] = rendererKey(renderer))) {
1881
1899
  setConditionalRenderer(scope, nodeAccessor, renderer, createAndSetupBranch);
1882
1900
  if (renderer?.["accessor"]) subscribeToScopeSet(renderer[Owner], renderer[Accessor], scope[childScopeAccessor]);
1883
1901
  }
@@ -254,10 +254,16 @@ function assertExclusiveAttrs(attrs, onError = throwErr) {
254
254
  (exclusiveAttrs ||= []).push("checkedValueChange");
255
255
  if ("checked" in attrs) exclusiveAttrs.push("checked");
256
256
  }
257
- if (attrs.valueChange) (exclusiveAttrs ||= []).push("valueChange");
257
+ if (attrs.valueChange) {
258
+ (exclusiveAttrs ||= []).push("valueChange");
259
+ if ("checked" in attrs && !exclusiveAttrs.includes("checked")) exclusiveAttrs.push("checked");
260
+ }
258
261
  if (exclusiveAttrs && exclusiveAttrs.length > 1) onError(`The attributes ${joinWithAnd(exclusiveAttrs)} are mutually exclusive.`);
259
262
  }
260
263
  }
264
+ function assertNoValueBindingOnCheckable(type, valueChange) {
265
+ if (valueChange && /^(?:button|checkbox|hidden|image|radio|reset|submit)$/i.test(type)) console.error(`\`valueChange\` cannot be used on a \`type="${type}"\` \`<input>\` — user interaction can never change its \`value\`.` + (/^[cr]/i.test(type) ? " Bind `checked` or `checkedValue` instead." : ""));
266
+ }
261
267
  function assertHandlerIsFunction(name, value) {
262
268
  if (value && typeof value !== "function") throw new Error(`The \`${name}\` handler must be a function or a falsey value (\`null\`, \`undefined\`, \`false\`, \`0\`, …), but received type "${typeof value}".`);
263
269
  }
@@ -742,10 +748,16 @@ const _var_change = (scope, value, name = "This") => {
742
748
  scope[TagVariableChange](value);
743
749
  };
744
750
  const tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
745
- function _id({ [Global]: $global }) {
746
- const id = tagIdsByGlobal.get($global) || 0;
747
- tagIdsByGlobal.set($global, id + 1);
748
- return "c" + $global.runtimeId + $global.renderId + id.toString(36);
751
+ function _id(scope, accessor) {
752
+ let id = accessor !== void 0 && scope[accessor];
753
+ if (!id) {
754
+ const $global = scope[Global];
755
+ const n = tagIdsByGlobal.get($global) || 0;
756
+ tagIdsByGlobal.set($global, n + 1);
757
+ id = "c" + $global.runtimeId + $global.renderId + n.toString(36);
758
+ if (accessor !== void 0) scope[accessor] = id;
759
+ }
760
+ return id;
749
761
  }
750
762
  function _script(id, fn) {
751
763
  _resume(id, fn);
@@ -757,19 +769,19 @@ function _el_read(value) {
757
769
  if (rendering) _el_read_error();
758
770
  return value;
759
771
  }
760
- function* traverse(scope, path, i = path.length - 1) {
772
+ function* traverse(scope, path, args, i = path.length - 1) {
761
773
  if (rendering) _hoist_read_error();
762
- if (scope) if (Symbol.iterator in scope) for (const childScope of scope.values()) yield* traverse(childScope, path, i);
774
+ if (scope) if (Symbol.iterator in scope) for (const childScope of scope.values()) yield* traverse(childScope, path, args, i);
763
775
  else {
764
776
  const item = scope[path[i]];
765
- if (i) yield* traverse(item, path, i - 1);
766
- else yield typeof item === "function" ? item() : item;
777
+ if (i) yield* traverse(item, path, args, i - 1);
778
+ else yield typeof item === "function" ? item(...args) : item;
767
779
  }
768
780
  }
769
781
  function _hoist(...path) {
770
782
  return (scope) => {
771
- const fn = () => traverse(scope, path).next().value;
772
- fn[Symbol.iterator] = () => traverse(scope, path);
783
+ const fn = (...args) => traverse(scope, path, args).next().value;
784
+ fn[Symbol.iterator] = () => traverse(scope, path, []);
773
785
  return fn;
774
786
  };
775
787
  }
@@ -1236,7 +1248,7 @@ function attrsInternal(scope, nodeAccessor, nextAttrs, controllable) {
1236
1248
  }
1237
1249
  function _attr_content(scope, nodeAccessor, value) {
1238
1250
  const content = normalizeClientRender(value);
1239
- if (scope["ConditionalRenderer:" + nodeAccessor] !== (scope["ConditionalRenderer:" + nodeAccessor] = content?.["id"])) {
1251
+ if (scope["ConditionalRenderer:" + nodeAccessor] !== (scope["ConditionalRenderer:" + nodeAccessor] = rendererKey(content))) {
1240
1252
  setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch);
1241
1253
  if (content?.["accessor"]) subscribeToScopeSet(content[Owner], content[Accessor], scope[BranchScopes$1 + nodeAccessor]);
1242
1254
  }
@@ -1416,17 +1428,19 @@ function _attr_input_value(scope, nodeAccessor, value, valueChange, setDefault =
1416
1428
  const el = scope[nodeAccessor];
1417
1429
  const normalizedValue = normalizeAttrValue(value) || "";
1418
1430
  assertHandlerIsFunction("valueChange", valueChange);
1431
+ assertNoValueBindingOnCheckable(el.type, valueChange);
1419
1432
  scope[ControlledHandler + nodeAccessor] = valueChange;
1420
1433
  scope[ControlledValue + nodeAccessor] = normalizedValue;
1421
1434
  scope[ControlledType + nodeAccessor] = valueChange ? 2 : 5;
1422
1435
  if (valueChange && scope["#Gen"] < runId) setInputValue(el, normalizedValue);
1423
- else setDefault(scope, nodeAccessor, normalizedValue);
1436
+ else setDefault(scope, nodeAccessor, value);
1424
1437
  }
1425
1438
  function _attr_input_value_attribute_default(scope, nodeAccessor, value) {
1426
1439
  _attr(scope[nodeAccessor], "value", value);
1427
1440
  }
1428
1441
  function _attr_input_value_script(scope, nodeAccessor) {
1429
1442
  const el = scope[nodeAccessor];
1443
+ assertNoValueBindingOnCheckable(el.type, scope[ControlledHandler + nodeAccessor]);
1430
1444
  if (isResuming) scope[ControlledValue + nodeAccessor] = el.defaultValue;
1431
1445
  syncControllableFormInput(el, hasValueChanged, (ev) => {
1432
1446
  const valueChange = scope[ControlledHandler + nodeAccessor];
@@ -1834,6 +1848,9 @@ const _show = /*@__PURE__*/ withBranches((nodeAccessor, startNodeAccessor, endNo
1834
1848
  }
1835
1849
  };
1836
1850
  });
1851
+ function rendererKey(renderer) {
1852
+ return renderer?.["owner"] ? renderer["id"] + " " + renderer[Owner]["#Id"] : renderer?.["id"] || renderer;
1853
+ }
1837
1854
  function patchDynamicTag(fn) {
1838
1855
  _dynamic_tag = fn(_dynamic_tag);
1839
1856
  }
@@ -1842,9 +1859,10 @@ let _dynamic_tag = /*@__PURE__*/ withBranches((nodeAccessor, getContent, getTagV
1842
1859
  const rendererAccessor = ConditionalRenderer + nodeAccessor;
1843
1860
  return (scope, newRenderer, getInput) => {
1844
1861
  const normalizedRenderer = normalizeDynamicRenderer(newRenderer);
1845
- if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.["id"] || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor])) {
1862
+ if (scope[rendererAccessor] !== (scope[rendererAccessor] = rendererKey(normalizedRenderer)) || getContent && !(normalizedRenderer || scope[childScopeAccessor])) {
1846
1863
  setConditionalRenderer(scope, nodeAccessor, normalizedRenderer || (getContent ? getContent(scope) : void 0), createBranchWithTagNameOrRenderer);
1847
- if (getTagVar) scope[childScopeAccessor][TagVariable] = (value) => getTagVar()(scope, value);
1864
+ if (getTagVar) if (scope[childScopeAccessor]) scope[childScopeAccessor][TagVariable] = (value) => getTagVar()(scope, value);
1865
+ else getTagVar()(scope, void 0);
1848
1866
  if (typeof normalizedRenderer === "string") {
1849
1867
  if (getContent) {
1850
1868
  const content = getContent(scope);
@@ -1878,7 +1896,7 @@ const _dynamic_tag_content = /*@__PURE__*/ withBranches((nodeAccessor) => {
1878
1896
  const childScopeAccessor = BranchScopes$1 + nodeAccessor;
1879
1897
  const rendererAccessor = ConditionalRenderer + nodeAccessor;
1880
1898
  return (scope, renderer) => {
1881
- if (scope[rendererAccessor] !== (scope[rendererAccessor] = renderer?.["id"] || renderer)) {
1899
+ if (scope[rendererAccessor] !== (scope[rendererAccessor] = rendererKey(renderer))) {
1882
1900
  setConditionalRenderer(scope, nodeAccessor, renderer, createAndSetupBranch);
1883
1901
  if (renderer?.["accessor"]) subscribeToScopeSet(renderer[Owner], renderer[Accessor], scope[childScopeAccessor]);
1884
1902
  }
package/dist/debug/dom.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const require_control_flow = require("./dom-Bj58jt8y.js");
3
+ const require_control_flow = require("./dom-Bt4OoZ-j.js");
4
4
  //#region src/common/attr-tag.ts
5
5
  const empty = [];
6
6
  const rest = Symbol("Attribute Tag");
@@ -1,4 +1,4 @@
1
- import { $ as _html, $t as queueEffect, A as _attr_select_value, At as _id, B as _attr_class, Bt as _assert_init, C as _attr_input_checked_default, Ct as _closure_get, D as _attr_input_value_default, Dt as _for_selector, E as _attr_input_value_attribute_default, Et as _for_closure, F as _controllable_select, Ft as _return, G as _attr_style, Gt as _on, H as _attr_class_items, Ht as insertBranchBefore, I as _controllable_textarea, It as _return_change, J as _attrs, K as _attr_style_item, Kt as $signal, Lt as _script, M as _attr_select_value_script, Mt as _let, N as _controllable_input, Nt as _let_change, O as _attr_input_value_dynamic_default, Ot as _hoist, P as _controllable_open, Pt as _or, Q as _attrs_script, Qt as queueAsyncRender, Rt as _var, S as _attr_input_checkedValue_script, St as _closure, T as _attr_input_value, Tn as TagVariable, Tt as _el_read, U as _attr_content, Ut as removeAndDestroyBranch, V as _attr_class_item, Vt as destroyBranch, W as _attr_nonce, Wt as syncGen, X as _attrs_partial, Y as _attrs_content, Z as _attrs_partial_content, Zt as prepareEffects, _ as _attr_details_or_dialog_open_default, _n as EndNode, _t as getRegisteredWithScope, a as _for_in, an as forTo, at as _to_text, b as _attr_input_checkedValue, bn as Load, bt as ready, c as _for_until, cn as _call, ct as _content, d as _show, dn as Params, dt as createAndSetupBranch, en as run, et as _lifecycle, f as _try, fn as Setup, ft as createBranch, g as _attr_details_or_dialog_open, gt as _var_resume, h as renderCatch, ht as _resume, i as _dynamic_tag_content, in as forOf, it as _text_content, j as _attr_select_value_default, jt as _if_closure, k as _attr_input_value_script, kt as _hoist_resume, l as _if, ln as Clone, lt as _content_closures, m as patchDynamicTag, mt as _el, n as _await_promise, nn as runId, nt as _style_shell, o as _for_of, on as forUntil, ot as insertChildNodes, p as addAwaitCounter, pt as setupBranch, q as _attr_style_items, qt as $signalReset, r as _dynamic_tag, rn as forIn, rt as _text, s as _for_to, sn as _assert_hoist, st as toInsertNode, t as _await_content, tn as runEffects, tt as _style_rule_item, u as _resume_dynamic_tag, un as Owner, ut as _content_resume, v as _attr_details_or_dialog_open_script, vt as init, w as _attr_input_checked_script, wn as StartNode, wt as _const, x as _attr_input_checkedValue_default, xt as _child_setup, y as _attr_input_checked, yn as Global, yt as initEmbedded, z as _attr, zt as _var_change } from "./dom-klf8Ec_o.mjs";
1
+ import { $ as _html, $t as queueEffect, A as _attr_select_value, At as _id, B as _attr_class, Bt as _assert_init, C as _attr_input_checked_default, Ct as _closure_get, D as _attr_input_value_default, Dt as _for_selector, E as _attr_input_value_attribute_default, Et as _for_closure, F as _controllable_select, Ft as _return, G as _attr_style, Gt as _on, H as _attr_class_items, Ht as insertBranchBefore, I as _controllable_textarea, It as _return_change, J as _attrs, K as _attr_style_item, Kt as $signal, Lt as _script, M as _attr_select_value_script, Mt as _let, N as _controllable_input, Nt as _let_change, O as _attr_input_value_dynamic_default, Ot as _hoist, P as _controllable_open, Pt as _or, Q as _attrs_script, Qt as queueAsyncRender, Rt as _var, S as _attr_input_checkedValue_script, St as _closure, T as _attr_input_value, Tn as TagVariable, Tt as _el_read, U as _attr_content, Ut as removeAndDestroyBranch, V as _attr_class_item, Vt as destroyBranch, W as _attr_nonce, Wt as syncGen, X as _attrs_partial, Y as _attrs_content, Z as _attrs_partial_content, Zt as prepareEffects, _ as _attr_details_or_dialog_open_default, _n as EndNode, _t as getRegisteredWithScope, a as _for_in, an as forTo, at as _to_text, b as _attr_input_checkedValue, bn as Load, bt as ready, c as _for_until, cn as _call, ct as _content, d as _show, dn as Params, dt as createAndSetupBranch, en as run, et as _lifecycle, f as _try, fn as Setup, ft as createBranch, g as _attr_details_or_dialog_open, gt as _var_resume, h as renderCatch, ht as _resume, i as _dynamic_tag_content, in as forOf, it as _text_content, j as _attr_select_value_default, jt as _if_closure, k as _attr_input_value_script, kt as _hoist_resume, l as _if, ln as Clone, lt as _content_closures, m as patchDynamicTag, mt as _el, n as _await_promise, nn as runId, nt as _style_shell, o as _for_of, on as forUntil, ot as insertChildNodes, p as addAwaitCounter, pt as setupBranch, q as _attr_style_items, qt as $signalReset, r as _dynamic_tag, rn as forIn, rt as _text, s as _for_to, sn as _assert_hoist, st as toInsertNode, t as _await_content, tn as runEffects, tt as _style_rule_item, u as _resume_dynamic_tag, un as Owner, ut as _content_resume, v as _attr_details_or_dialog_open_script, vt as init, w as _attr_input_checked_script, wn as StartNode, wt as _const, x as _attr_input_checkedValue_default, xt as _child_setup, y as _attr_input_checked, yn as Global, yt as initEmbedded, z as _attr, zt as _var_change } from "./dom-B57LrRnX.mjs";
2
2
  //#region src/common/attr-tag.ts
3
3
  const empty = [];
4
4
  const rest = Symbol("Attribute Tag");