Match-id-2a4d49b90b105db41f89732a409a878541bd1263
This commit is contained in:
parent
b27cb830dc
commit
3410a9cc00
|
@ -4,17 +4,19 @@ import {throwNotInFuncError} from '../../hooks/BaseHook';
|
||||||
|
|
||||||
// 重置依赖
|
// 重置依赖
|
||||||
export function resetDepContexts(vNode: VNode): void {
|
export function resetDepContexts(vNode: VNode): void {
|
||||||
vNode.depContexts = [];
|
vNode.depContexts = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 收集依赖
|
// 收集依赖
|
||||||
function collectDeps<T>(vNode: VNode, context: ContextType<T>) {
|
function collectDeps<T>(vNode: VNode, context: ContextType<T>) {
|
||||||
const depContexts = vNode.depContexts;
|
const depContexts = vNode.depContexts;
|
||||||
if (!depContexts.length) {
|
if (depContexts === null) {
|
||||||
|
vNode.depContexts = [context];
|
||||||
|
} else {
|
||||||
vNode.isDepContextChange = false;
|
vNode.isDepContextChange = false;
|
||||||
}
|
if (!depContexts.includes(context)) {
|
||||||
if (!depContexts.includes(context)) {
|
depContexts.push(context);
|
||||||
depContexts.push(context);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ function handleContextChange(processing: VNode, context: ContextType<any>): void
|
||||||
// 从vNode开始遍历
|
// 从vNode开始遍历
|
||||||
travelVNodeTree(vNode, node => {
|
travelVNodeTree(vNode, node => {
|
||||||
const depContexts = node.depContexts;
|
const depContexts = node.depContexts;
|
||||||
if (depContexts.length) {
|
if (depContexts && depContexts.length) {
|
||||||
isMatch = matchDependencies(depContexts, context, node) ?? isMatch;
|
isMatch = matchDependencies(depContexts, context, node) ?? isMatch;
|
||||||
}
|
}
|
||||||
}, node =>
|
}, node =>
|
||||||
|
|
|
@ -33,7 +33,7 @@ export class VNode {
|
||||||
state: any = null; // ClassComponent和TreeRoot的状态
|
state: any = null; // ClassComponent和TreeRoot的状态
|
||||||
hooks: Array<Hook<any, any>> | null = null; // 保存hook
|
hooks: Array<Hook<any, any>> | null = null; // 保存hook
|
||||||
suspenseChildStatus: string = ''; // Suspense的Children是否显示
|
suspenseChildStatus: string = ''; // Suspense的Children是否显示
|
||||||
depContexts: Array<ContextType<any>> | null = []; // FunctionComponent和ClassComponent对context的依赖列表
|
depContexts: Array<ContextType<any>> | null = null; // FunctionComponent和ClassComponent对context的依赖列表
|
||||||
isDepContextChange: boolean = false; // context是否变更
|
isDepContextChange: boolean = false; // context是否变更
|
||||||
dirtyNodes: Array<VNode> | null = null; // 需要改动的节点数组
|
dirtyNodes: Array<VNode> | null = null; // 需要改动的节点数组
|
||||||
shouldUpdate: boolean = false;
|
shouldUpdate: boolean = false;
|
||||||
|
|
Loading…
Reference in New Issue