Match-id-7bdd5aa7851d0fb3ba0271c01879051dea1ccf20

This commit is contained in:
* 2022-09-07 21:09:50 +08:00 committed by *
parent 77be7a916a
commit 9916cab3f7
3 changed files with 9 additions and 1 deletions

View File

@ -176,7 +176,12 @@ export function calcStartUpdateVNode(treeRoot: VNode) {
}
if (toUpdateNodes.length === 1) {
return toUpdateNodes[0];
const toUpdateNode = toUpdateNodes[0];
if (toUpdateNode.isCleared) {
return treeRoot;
} else {
return toUpdateNodes[0];
}
}
// 要计算的节点过多,直接返回根节点

View File

@ -39,6 +39,8 @@ export class VNode {
ref: RefType | ((handle: any) => void) | null = null; // 包裹一个函数submit阶段使用比如将外部useRef生成的对象赋值到ref上
oldProps: any = null;
// 是否已经被从树上移除
isCleared = false;
changeList: any; // DOM的变更列表
effectList: any[] | null; // useEffect 的更新数组
updates: any[] | null; // TreeRoot和ClassComponent使用的更新数组

View File

@ -73,6 +73,7 @@ export function travelVNodeTree(
// 置空vNode
export function clearVNode(vNode: VNode) {
vNode.isCleared = true;
vNode.child = null;
vNode.next = null;
vNode.depContexts = null;