@mintjamsinc/ichigojs 0.1.38 → 0.1.40
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/ichigo.cjs +36 -18
- package/dist/ichigo.cjs.map +1 -1
- package/dist/ichigo.esm.js +36 -18
- package/dist/ichigo.esm.js.map +1 -1
- package/dist/ichigo.esm.min.js +1 -1
- package/dist/ichigo.min.cjs +1 -1
- package/dist/ichigo.umd.js +36 -18
- package/dist/ichigo.umd.js.map +1 -1
- package/dist/ichigo.umd.min.js +1 -1
- package/package.json +1 -1
package/dist/ichigo.cjs
CHANGED
|
@@ -8335,6 +8335,10 @@
|
|
|
8335
8335
|
}
|
|
8336
8336
|
}
|
|
8337
8337
|
}
|
|
8338
|
+
// Remove anchor node from DOM if it exists
|
|
8339
|
+
if (this.#anchorNode?.parentNode) {
|
|
8340
|
+
this.#anchorNode.parentNode.removeChild(this.#anchorNode);
|
|
8341
|
+
}
|
|
8338
8342
|
}
|
|
8339
8343
|
#parseDirectives() {
|
|
8340
8344
|
const element = this.#vNode.node;
|
|
@@ -9345,7 +9349,8 @@
|
|
|
9345
9349
|
* @inheritdoc
|
|
9346
9350
|
*/
|
|
9347
9351
|
destroy() {
|
|
9348
|
-
//
|
|
9352
|
+
// Clean up the rendered VNode if it exists
|
|
9353
|
+
this.#removedNode();
|
|
9349
9354
|
}
|
|
9350
9355
|
/**
|
|
9351
9356
|
* Renders the node based on the evaluation of the directive's condition.
|
|
@@ -9387,10 +9392,12 @@
|
|
|
9387
9392
|
// Insert the cloned node after the anchor node, or as a child of the parent if no anchor
|
|
9388
9393
|
this.#vNode.anchorNode?.parentNode?.insertBefore(clone, this.#vNode.anchorNode.nextSibling);
|
|
9389
9394
|
// Create a new VNode for the cloned element
|
|
9395
|
+
// Pass the current bindings to ensure loop variables from v-for are available
|
|
9390
9396
|
const vNode = new VNode({
|
|
9391
9397
|
node: clone,
|
|
9392
9398
|
vApplication: this.#vNode.vApplication,
|
|
9393
|
-
parentVNode: this.#vNode
|
|
9399
|
+
parentVNode: this.#vNode,
|
|
9400
|
+
bindings: this.#vNode.bindings
|
|
9394
9401
|
});
|
|
9395
9402
|
this.#renderedVNode = vNode;
|
|
9396
9403
|
this.#renderedVNode.forceUpdate();
|
|
@@ -9748,13 +9755,6 @@
|
|
|
9748
9755
|
if (!vNode) {
|
|
9749
9756
|
// Create new item
|
|
9750
9757
|
const clone = this.#cloneNode();
|
|
9751
|
-
// Insert after previous node
|
|
9752
|
-
if (prevNode.nextSibling) {
|
|
9753
|
-
parent.insertBefore(clone, prevNode.nextSibling);
|
|
9754
|
-
}
|
|
9755
|
-
else {
|
|
9756
|
-
parent.appendChild(clone);
|
|
9757
|
-
}
|
|
9758
9758
|
// Create bindings for this iteration
|
|
9759
9759
|
const bindings = new VBindings({
|
|
9760
9760
|
parent: this.#vNode.bindings
|
|
@@ -9762,16 +9762,31 @@
|
|
|
9762
9762
|
// Set item bindings (handles nested destructuring)
|
|
9763
9763
|
this.#setItemBindings(bindings, context);
|
|
9764
9764
|
// Create a new VNode for the cloned element
|
|
9765
|
+
// Note: VNode creation must happen BEFORE DOM insertion because
|
|
9766
|
+
// directives like v-if may modify the DOM structure (create anchors, remove template elements)
|
|
9767
|
+
let depIds = [
|
|
9768
|
+
`${this.#sourceName}[${context.index}]`,
|
|
9769
|
+
...this.#vNode.vApplication.resolveDependentIdentifiers(this.#sourceName, context.item)
|
|
9770
|
+
];
|
|
9771
|
+
if (this.#itemName) {
|
|
9772
|
+
depIds.push(this.#itemName);
|
|
9773
|
+
}
|
|
9765
9774
|
vNode = new VNode({
|
|
9766
9775
|
node: clone,
|
|
9767
9776
|
vApplication: this.#vNode.vApplication,
|
|
9768
|
-
parentVNode: this.#vNode
|
|
9777
|
+
parentVNode: this.#vNode,
|
|
9769
9778
|
bindings,
|
|
9770
|
-
dependentIdentifiers:
|
|
9771
|
-
`${this.#sourceName}[${context.index}]`,
|
|
9772
|
-
...this.#vNode.vApplication.resolveDependentIdentifiers(this.#sourceName, context.item)
|
|
9773
|
-
],
|
|
9779
|
+
dependentIdentifiers: depIds,
|
|
9774
9780
|
});
|
|
9781
|
+
// Determine what to insert: anchor node (if exists) or the clone itself
|
|
9782
|
+
const nodeToInsert = vNode.anchorNode || clone;
|
|
9783
|
+
// Insert after previous node
|
|
9784
|
+
if (prevNode.nextSibling) {
|
|
9785
|
+
parent.insertBefore(nodeToInsert, prevNode.nextSibling);
|
|
9786
|
+
}
|
|
9787
|
+
else {
|
|
9788
|
+
parent.appendChild(nodeToInsert);
|
|
9789
|
+
}
|
|
9775
9790
|
newRenderedItems.set(key, vNode);
|
|
9776
9791
|
vNode.forceUpdate();
|
|
9777
9792
|
}
|
|
@@ -9780,17 +9795,20 @@
|
|
|
9780
9795
|
newRenderedItems.set(key, vNode);
|
|
9781
9796
|
// Update bindings
|
|
9782
9797
|
this.#updateItemBindings(vNode, context);
|
|
9798
|
+
// Determine the actual node in DOM: anchor node (if exists) or vNode.node
|
|
9799
|
+
const actualNode = vNode.anchorNode || vNode.node;
|
|
9783
9800
|
// Move to correct position if needed
|
|
9784
|
-
if (prevNode.nextSibling !==
|
|
9801
|
+
if (prevNode.nextSibling !== actualNode) {
|
|
9785
9802
|
if (prevNode.nextSibling) {
|
|
9786
|
-
parent.insertBefore(
|
|
9803
|
+
parent.insertBefore(actualNode, prevNode.nextSibling);
|
|
9787
9804
|
}
|
|
9788
9805
|
else {
|
|
9789
|
-
parent.appendChild(
|
|
9806
|
+
parent.appendChild(actualNode);
|
|
9790
9807
|
}
|
|
9791
9808
|
}
|
|
9792
9809
|
}
|
|
9793
|
-
prevNode
|
|
9810
|
+
// Use anchor node as prevNode if it exists, otherwise use vNode.node
|
|
9811
|
+
prevNode = vNode.anchorNode || vNode.node;
|
|
9794
9812
|
}
|
|
9795
9813
|
// Update rendered items map
|
|
9796
9814
|
this.#renderedItems = newRenderedItems;
|