From a39db5b6f9c59a96222a3c174f934ea40fb83878 Mon Sep 17 00:00:00 2001 From: * <8> Date: Tue, 1 Nov 2022 20:38:46 +0800 Subject: [PATCH] Match-id-b6f9fc4a755903e35420b220d2b1dc6edd52fe24 --- .../horizon/src/renderer/diff/nodeDiffComparator.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libs/horizon/src/renderer/diff/nodeDiffComparator.ts b/libs/horizon/src/renderer/diff/nodeDiffComparator.ts index 56753063..4186d361 100644 --- a/libs/horizon/src/renderer/diff/nodeDiffComparator.ts +++ b/libs/horizon/src/renderer/diff/nodeDiffComparator.ts @@ -351,7 +351,7 @@ function diffArrayNodesHandler(parentNode: VNode, firstChild: VNode | null, newC if (rightNewNode) { appendNode(rightNewNode); - setVNodesCIndex(rightNewNode, prevNewNode.cIndex + 1); + setVNodesCIndex(rightNewNode, rightNewNode.cIndex + 1); } return resultingFirstChild; @@ -498,10 +498,10 @@ function diffIteratorNodesHandler( newChildrenIterable: Iterable ): VNode | null { const iteratorFn = getIteratorFn(newChildrenIterable); - const iteratorObj = iteratorFn.call(newChildrenIterable); + const iteratorObj: Iterator = iteratorFn.call(newChildrenIterable); // 把iterator转测数组 - const childrenArray = []; + const childrenArray: any[] = []; let result = iteratorObj.next(); while (!result.done) { childrenArray.push(result.value); @@ -512,7 +512,7 @@ function diffIteratorNodesHandler( } // 新节点是字符串类型 -function diffStringNodeHandler(parentNode: VNode, newChild: any, firstChildVNode: VNode, isComparing: boolean) { +function diffStringNodeHandler(parentNode: VNode, newChild: any, firstChildVNode: VNode | null, isComparing: boolean) { let newTextNode: VNode | null = null; // 第一个vNode是Text,则复用 @@ -540,7 +540,6 @@ function diffObjectNodeHandler( parentNode: VNode, firstChild: VNode | null, newChild: any, - firstChildVNode: VNode, isComparing: boolean ) { let canReuseNode: VNode | null = null; @@ -559,7 +558,7 @@ function diffObjectNodeHandler( } let resultNode: VNode | null = null; - let startDelVNode = firstChildVNode; + let startDelVNode: VNode | null = firstChild; if (newChild.vtype === TYPE_COMMON_ELEMENT) { if (canReuseNode) { // 可以复用 @@ -654,7 +653,7 @@ export function createChildrenByDiff( // 5. newChild是对象类型 if (isObjectType(newChild)) { - const newVNodes = diffObjectNodeHandler(parentNode, firstChild, newChild, firstChild, isComparing); + const newVNodes = diffObjectNodeHandler(parentNode, firstChild, newChild, isComparing); if (newVNodes) { return newVNodes; }