Match-id-b6f9fc4a755903e35420b220d2b1dc6edd52fe24

This commit is contained in:
* 2022-11-01 20:38:46 +08:00 committed by *
parent 3833d0501a
commit a39db5b6f9
1 changed files with 6 additions and 7 deletions

View File

@ -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<any>
): VNode | null {
const iteratorFn = getIteratorFn(newChildrenIterable);
const iteratorObj = iteratorFn.call(newChildrenIterable);
const iteratorObj: Iterator<any> = 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;
}