@3sln/dodo 0.0.6 → 0.0.7
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/package.json +1 -1
- package/src/vdom.js +35 -37
package/package.json
CHANGED
package/src/vdom.js
CHANGED
|
@@ -13,7 +13,7 @@ class VNode {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
key(k) {
|
|
16
|
-
this.
|
|
16
|
+
this.k = k;
|
|
17
17
|
return this;
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -525,35 +525,33 @@ export default userSettings => {
|
|
|
525
525
|
|
|
526
526
|
function cleanupTarget(target) {
|
|
527
527
|
const state = target[NODE_STATE];
|
|
528
|
-
if (state) {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
}
|
|
552
|
-
try {
|
|
553
|
-
state.vdom.hooks?.$detach?.(target);
|
|
554
|
-
} catch (err) {
|
|
555
|
-
console.error(err);
|
|
528
|
+
if (!state) {
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
const {vdom} = state;
|
|
533
|
+
|
|
534
|
+
if (vdom.hooks) {
|
|
535
|
+
reconcileListeners(target, EMPTY_MAP);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
if (vdom.type === ELEMENT_NODE || vdom.type === OPAQUE_NODE) {
|
|
539
|
+
reconcileElementProps(target, EMPTY_MAP);
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
if (vdom.type === ELEMENT_NODE || vdom.type === ALIAS_NODE) {
|
|
543
|
+
cleanupTargetChildren(target);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
delete target[NODE_STATE];
|
|
547
|
+
|
|
548
|
+
try {
|
|
549
|
+
if (vdom.type === SPECIAL_NODE) {
|
|
550
|
+
vdom.tag.detach?.(target);
|
|
556
551
|
}
|
|
552
|
+
vdom.hooks?.$detach?.(target);
|
|
553
|
+
} catch (err) {
|
|
554
|
+
console.error(err);
|
|
557
555
|
}
|
|
558
556
|
}
|
|
559
557
|
|
|
@@ -581,17 +579,17 @@ export default userSettings => {
|
|
|
581
579
|
|
|
582
580
|
let oldNodesPoolForTag = oldVNodeNodesPool.get(vdom.tag);
|
|
583
581
|
if (!oldNodesPoolForTag) {
|
|
584
|
-
oldNodesPoolForTag = {nodesForKey:
|
|
582
|
+
oldNodesPoolForTag = {nodesForKey: newMap({}), nodesWithoutKey: []};
|
|
585
583
|
oldVNodeNodesPool.set(vdom.tag, oldNodesPoolForTag);
|
|
586
584
|
}
|
|
587
585
|
|
|
588
|
-
if (vdom.
|
|
589
|
-
let oldNodesPoolForKey = oldNodesPoolForTag.nodesForKey
|
|
586
|
+
if (vdom.k !== undefined) {
|
|
587
|
+
let oldNodesPoolForKey = mapGet(oldNodesPoolForTag.nodesForKey, vdom.k);
|
|
590
588
|
if (oldNodesPoolForKey === undefined) {
|
|
591
589
|
oldNodesPoolForKey = [];
|
|
592
|
-
oldNodesPoolForTag.nodesForKey.set(vdom.key, oldNodesPoolForKey);
|
|
593
590
|
}
|
|
594
591
|
oldNodesPoolForKey.push(oldChild);
|
|
592
|
+
oldNodesPoolForTag.nodesForKey = mapPut(oldNodesPoolForTag.nodesForKey, vdom.k, oldNodesPoolForKey);
|
|
595
593
|
} else {
|
|
596
594
|
oldNodesPoolForTag.nodesWithoutKey.push(oldChild);
|
|
597
595
|
}
|
|
@@ -605,15 +603,15 @@ export default userSettings => {
|
|
|
605
603
|
if (!oldNodesPoolForTag) {
|
|
606
604
|
newDomNode = createNode(target, newVdom);
|
|
607
605
|
} else {
|
|
608
|
-
const key = newVdom.
|
|
606
|
+
const key = newVdom.k;
|
|
609
607
|
if (key !== undefined) {
|
|
610
|
-
const pool = oldNodesPoolForTag.nodesForKey
|
|
608
|
+
const pool = mapGet(oldNodesPoolForTag.nodesForKey, key);
|
|
611
609
|
if (pool && pool.length > 0) {
|
|
612
610
|
newDomNode = pool.shift();
|
|
613
611
|
const state = newDomNode[NODE_STATE];
|
|
614
612
|
if (shouldUpdate(state.vdom.args, newVdom.args)) {
|
|
615
613
|
if (state.vdom.hooks || newVdom.hooks) {
|
|
616
|
-
reconcileListeners(
|
|
614
|
+
reconcileListeners(newDomNode, newVdom.hooks);
|
|
617
615
|
}
|
|
618
616
|
state.newVdom = newVdom;
|
|
619
617
|
}
|
|
@@ -627,7 +625,7 @@ export default userSettings => {
|
|
|
627
625
|
const state = newDomNode[NODE_STATE];
|
|
628
626
|
if (shouldUpdate(state.vdom.args, newVdom.args)) {
|
|
629
627
|
if (state.vdom.hooks || newVdom.hooks) {
|
|
630
|
-
reconcileListeners(
|
|
628
|
+
reconcileListeners(newDomNode, newVdom.hooks);
|
|
631
629
|
}
|
|
632
630
|
state.newVdom = newVdom;
|
|
633
631
|
}
|