@mintjamsinc/ichigojs 0.1.18 → 0.1.19

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.
@@ -8818,8 +8818,17 @@
8818
8818
  // Already rendered, no action needed
8819
8819
  return;
8820
8820
  }
8821
- this.#renderedVNode = this.#cloneTemplate();
8822
- this.#vNode.anchorNode?.parentNode?.insertBefore(this.#renderedVNode.node, this.#vNode.anchorNode.nextSibling);
8821
+ // Clone the original node and create a new VNode for it
8822
+ const clone = this.#cloneNode();
8823
+ // Insert the cloned node after the anchor node, or as a child of the parent if no anchor
8824
+ this.#vNode.anchorNode?.parentNode?.insertBefore(clone, this.#vNode.anchorNode.nextSibling);
8825
+ // Create a new VNode for the cloned element
8826
+ const vNode = new VNode({
8827
+ node: clone,
8828
+ vApplication: this.#vNode.vApplication,
8829
+ parentVNode: this.#vNode.parentVNode
8830
+ });
8831
+ this.#renderedVNode = vNode;
8823
8832
  this.#renderedVNode.forceUpdate();
8824
8833
  }
8825
8834
  /**
@@ -8838,19 +8847,13 @@
8838
8847
  this.#renderedVNode = undefined;
8839
8848
  }
8840
8849
  /**
8841
- * Clones the template element and creates a new VNode for the cloned element.
8850
+ * Clones the original node of the directive's virtual node.
8851
+ * This is used to create a new instance of the node for rendering.
8852
+ * @returns The cloned HTMLElement.
8842
8853
  */
8843
- #cloneTemplate() {
8844
- // Clone the original element
8854
+ #cloneNode() {
8845
8855
  const element = this.#vNode.node;
8846
- const clone = element.cloneNode(true);
8847
- // Create a new VNode for the cloned element
8848
- const vNode = new VNode({
8849
- node: clone,
8850
- vApplication: this.#vNode.vApplication,
8851
- parentVNode: this.#vNode.parentVNode
8852
- });
8853
- return vNode;
8856
+ return element.cloneNode(true);
8854
8857
  }
8855
8858
  /**
8856
8859
  * Creates a function to evaluate the directive's condition.
@@ -9190,15 +9193,36 @@
9190
9193
  let vNode = this.#renderedItems.get(key);
9191
9194
  if (!vNode) {
9192
9195
  // Create new item
9193
- vNode = this.#cloneTemplate(context);
9194
- newRenderedItems.set(key, vNode);
9196
+ const clone = this.#cloneNode();
9195
9197
  // Insert after previous node
9196
9198
  if (prevNode.nextSibling) {
9197
- parent.insertBefore(vNode.node, prevNode.nextSibling);
9199
+ parent.insertBefore(clone, prevNode.nextSibling);
9198
9200
  }
9199
9201
  else {
9200
- parent.appendChild(vNode.node);
9202
+ parent.appendChild(clone);
9203
+ }
9204
+ // Prepare identifiers for the item
9205
+ this.#itemName;
9206
+ this.#indexName;
9207
+ // Create bindings for this iteration
9208
+ const bindings = new VBindings({
9209
+ parent: this.#vNode.bindings
9210
+ });
9211
+ if (this.#itemName) {
9212
+ bindings.set(this.#itemName, context.item);
9213
+ }
9214
+ if (this.#indexName) {
9215
+ bindings.set(this.#indexName, context.index);
9201
9216
  }
9217
+ // Create a new VNode for the cloned element
9218
+ vNode = new VNode({
9219
+ node: clone,
9220
+ vApplication: this.#vNode.vApplication,
9221
+ parentVNode: this.#vNode.parentVNode,
9222
+ bindings,
9223
+ dependentIdentifiers: [`${this.#sourceName}[${context.index}]`]
9224
+ });
9225
+ newRenderedItems.set(key, vNode);
9202
9226
  vNode.forceUpdate();
9203
9227
  }
9204
9228
  else {
@@ -9274,34 +9298,14 @@
9274
9298
  };
9275
9299
  }
9276
9300
  /**
9277
- * Clone template element for each iteration and create a new VNode
9301
+ * Clones the original node of the directive's virtual node.
9302
+ * This is used to create a new instance of the node for rendering.
9303
+ * @returns The cloned HTMLElement.
9278
9304
  */
9279
- #cloneTemplate(context) {
9305
+ #cloneNode() {
9280
9306
  // Clone the original element
9281
9307
  const element = this.#vNode.node;
9282
- const clone = element.cloneNode(true);
9283
- // Prepare identifiers for the item
9284
- this.#itemName;
9285
- this.#indexName;
9286
- // Create bindings for this iteration
9287
- const bindings = new VBindings({
9288
- parent: this.#vNode.bindings
9289
- });
9290
- if (this.#itemName) {
9291
- bindings.set(this.#itemName, context.item);
9292
- }
9293
- if (this.#indexName) {
9294
- bindings.set(this.#indexName, context.index);
9295
- }
9296
- // Create a new VNode for the cloned element
9297
- const vNode = new VNode({
9298
- node: clone,
9299
- vApplication: this.#vNode.vApplication,
9300
- parentVNode: this.#vNode.parentVNode,
9301
- bindings,
9302
- dependentIdentifiers: [`${this.#sourceName}[${context.index}]`]
9303
- });
9304
- return vNode;
9308
+ return element.cloneNode(true);
9305
9309
  }
9306
9310
  /**
9307
9311
  * Update bindings for an existing item