Match-id-0626165d0ffc57291804485ab490ae368677280d

This commit is contained in:
* 2022-09-07 21:39:28 +08:00 committed by *
commit 50c670e6f1
5 changed files with 13 additions and 2 deletions

View File

@ -1,3 +1,6 @@
## 0.0.17 (2022-09-07)
- **core**: fix 不在树上的节点发起更新导致错误
## 0.0.16 (2022-09-07)
- **core**: #56,#65 diff null 不能正确卸载组件

View File

@ -4,7 +4,7 @@
"keywords": [
"horizon"
],
"version": "0.0.16",
"version": "0.0.17",
"homepage": "",
"bugs": "",
"main": "index.js",

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;