Match-id-b6f9fc4a755903e35420b220d2b1dc6edd52fe24
This commit is contained in:
parent
3833d0501a
commit
a39db5b6f9
|
@ -351,7 +351,7 @@ function diffArrayNodesHandler(parentNode: VNode, firstChild: VNode | null, newC
|
||||||
|
|
||||||
if (rightNewNode) {
|
if (rightNewNode) {
|
||||||
appendNode(rightNewNode);
|
appendNode(rightNewNode);
|
||||||
setVNodesCIndex(rightNewNode, prevNewNode.cIndex + 1);
|
setVNodesCIndex(rightNewNode, rightNewNode.cIndex + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return resultingFirstChild;
|
return resultingFirstChild;
|
||||||
|
@ -498,10 +498,10 @@ function diffIteratorNodesHandler(
|
||||||
newChildrenIterable: Iterable<any>
|
newChildrenIterable: Iterable<any>
|
||||||
): VNode | null {
|
): VNode | null {
|
||||||
const iteratorFn = getIteratorFn(newChildrenIterable);
|
const iteratorFn = getIteratorFn(newChildrenIterable);
|
||||||
const iteratorObj = iteratorFn.call(newChildrenIterable);
|
const iteratorObj: Iterator<any> = iteratorFn.call(newChildrenIterable);
|
||||||
|
|
||||||
// 把iterator转测数组
|
// 把iterator转测数组
|
||||||
const childrenArray = [];
|
const childrenArray: any[] = [];
|
||||||
let result = iteratorObj.next();
|
let result = iteratorObj.next();
|
||||||
while (!result.done) {
|
while (!result.done) {
|
||||||
childrenArray.push(result.value);
|
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;
|
let newTextNode: VNode | null = null;
|
||||||
|
|
||||||
// 第一个vNode是Text,则复用
|
// 第一个vNode是Text,则复用
|
||||||
|
@ -540,7 +540,6 @@ function diffObjectNodeHandler(
|
||||||
parentNode: VNode,
|
parentNode: VNode,
|
||||||
firstChild: VNode | null,
|
firstChild: VNode | null,
|
||||||
newChild: any,
|
newChild: any,
|
||||||
firstChildVNode: VNode,
|
|
||||||
isComparing: boolean
|
isComparing: boolean
|
||||||
) {
|
) {
|
||||||
let canReuseNode: VNode | null = null;
|
let canReuseNode: VNode | null = null;
|
||||||
|
@ -559,7 +558,7 @@ function diffObjectNodeHandler(
|
||||||
}
|
}
|
||||||
|
|
||||||
let resultNode: VNode | null = null;
|
let resultNode: VNode | null = null;
|
||||||
let startDelVNode = firstChildVNode;
|
let startDelVNode: VNode | null = firstChild;
|
||||||
if (newChild.vtype === TYPE_COMMON_ELEMENT) {
|
if (newChild.vtype === TYPE_COMMON_ELEMENT) {
|
||||||
if (canReuseNode) {
|
if (canReuseNode) {
|
||||||
// 可以复用
|
// 可以复用
|
||||||
|
@ -654,7 +653,7 @@ export function createChildrenByDiff(
|
||||||
|
|
||||||
// 5. newChild是对象类型
|
// 5. newChild是对象类型
|
||||||
if (isObjectType(newChild)) {
|
if (isObjectType(newChild)) {
|
||||||
const newVNodes = diffObjectNodeHandler(parentNode, firstChild, newChild, firstChild, isComparing);
|
const newVNodes = diffObjectNodeHandler(parentNode, firstChild, newChild, isComparing);
|
||||||
if (newVNodes) {
|
if (newVNodes) {
|
||||||
return newVNodes;
|
return newVNodes;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue