@mintjamsinc/ichigojs 0.1.73 → 0.1.74

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.
@@ -8434,6 +8434,13 @@ class VBindings {
8434
8434
  * Flag to suppress onChange callbacks temporarily.
8435
8435
  */
8436
8436
  #suppressOnChange = false;
8437
+ /**
8438
+ * Flag forcing the next write through the `set` trap to stay in THIS scope's own
8439
+ * local store instead of walking up to an inherited binding of the same name.
8440
+ * Set only by {@link setLocal} for scope-local variables (e.g. v-for loop items),
8441
+ * which must shadow — never overwrite — a parent binding with the same key.
8442
+ */
8443
+ #localWrite = false;
8437
8444
  /**
8438
8445
  * Per-instance path aliases. Maps local variable names to their reactive source paths.
8439
8446
  * Scoped here instead of the global ReactiveProxy map so that v-for items each maintain
@@ -8512,8 +8519,13 @@ class VBindings {
8512
8519
  setter(value);
8513
8520
  return true;
8514
8521
  }
8522
+ // For a key that is not local to this scope, an assignment normally
8523
+ // retargets to the nearest parent that owns it, so reassignments
8524
+ // (e.g. `count = count + 1` in a handler) mutate the original binding.
8525
+ // A scope-local write (setLocal — used for v-for loop variables) skips
8526
+ // this walk so the variable shadows, never clobbers, an inherited key.
8515
8527
  let target = obj;
8516
- if (!Reflect.has(target, key)) {
8528
+ if (!this.#localWrite && !Reflect.has(target, key)) {
8517
8529
  for (let parent = this.#parent; parent; parent = parent.#parent) {
8518
8530
  if (Reflect.has(parent.#local, key)) {
8519
8531
  target = parent.#local;
@@ -8688,6 +8700,25 @@ class VBindings {
8688
8700
  set(key, value) {
8689
8701
  this.#local[key] = value;
8690
8702
  }
8703
+ /**
8704
+ * Sets a binding value in THIS scope's own local store, without walking up to a
8705
+ * parent scope. Used for scope-local variables (e.g. v-for loop items) that must
8706
+ * shadow — never overwrite — an inherited binding of the same name. Contrast with
8707
+ * {@link set}, which retargets a write of an inherited key to the owning parent so
8708
+ * that reassignments mutate the original; a loop variable named like a root data /
8709
+ * method / computed key (e.g. `t`) would otherwise clobber it.
8710
+ * @param key The binding name.
8711
+ * @param value The binding value.
8712
+ */
8713
+ setLocal(key, value) {
8714
+ this.#localWrite = true;
8715
+ try {
8716
+ this.#local[key] = value;
8717
+ }
8718
+ finally {
8719
+ this.#localWrite = false;
8720
+ }
8721
+ }
8691
8722
  /**
8692
8723
  * Gets a binding value.
8693
8724
  * @param key The binding name.
@@ -10783,26 +10814,30 @@ class VForDirective {
10783
10814
  * Sets item bindings for a VNode, handling nested destructuring if needed.
10784
10815
  */
10785
10816
  #setItemBindings(bindings, context) {
10817
+ // Loop variables are scope-local: they must shadow, never overwrite, an
10818
+ // inherited binding of the same name (a data / method / computed key on a
10819
+ // parent scope). setLocal writes to this iteration's own store so a loop
10820
+ // variable named like e.g. the i18n helper `t` cannot clobber it.
10786
10821
  if (this.#itemDestructure && Array.isArray(context.item)) {
10787
10822
  // Nested destructuring: spread array items to individual bindings
10788
10823
  // e.g., item = ['alice', 1] with itemDestructure = ['k', 'v']
10789
- // bindings.set('k', 'alice')
10790
- // bindings.set('v', 1)
10824
+ // bindings.setLocal('k', 'alice')
10825
+ // bindings.setLocal('v', 1)
10791
10826
  this.#itemDestructure.forEach((name, i) => {
10792
- bindings.set(name, context.item[i]);
10827
+ bindings.setLocal(name, context.item[i]);
10793
10828
  });
10794
10829
  }
10795
10830
  else if (this.#itemName) {
10796
10831
  // Simple item binding
10797
- bindings.set(this.#itemName, context.item);
10832
+ bindings.setLocal(this.#itemName, context.item);
10798
10833
  }
10799
10834
  if (this.#indexName) {
10800
10835
  // For objects, use objectKey if available; otherwise use numeric index
10801
- bindings.set(this.#indexName, context.objectKey ?? context.index);
10836
+ bindings.setLocal(this.#indexName, context.objectKey ?? context.index);
10802
10837
  }
10803
10838
  if (this.#thirdName) {
10804
10839
  // Third argument is always the numeric index
10805
- bindings.set(this.#thirdName, context.index);
10840
+ bindings.setLocal(this.#thirdName, context.index);
10806
10841
  }
10807
10842
  }
10808
10843
  /**