From 712b9b42c10e59d67e1f199765e6f0c4b7febd25 Mon Sep 17 00:00:00 2001 From: * <8> Date: Fri, 1 Apr 2022 14:48:03 +0800 Subject: [PATCH] Match-id-2d3ad46152443e0e465ba7f54dc734e3cf1694af --- libs/horizon/src/renderer/ContextSaver.ts | 10 +++++----- libs/horizon/src/renderer/vnode/VNode.ts | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libs/horizon/src/renderer/ContextSaver.ts b/libs/horizon/src/renderer/ContextSaver.ts index 932a6ffa..6fd6ef9a 100644 --- a/libs/horizon/src/renderer/ContextSaver.ts +++ b/libs/horizon/src/renderer/ContextSaver.ts @@ -17,14 +17,14 @@ let ctxNamespace = ''; export function setNamespaceCtx(vNode: VNode, dom?: Container) { const nextContext = getNSCtx(ctxNamespace, vNode.type, dom); - vNode.contexts = ctxNamespace; + vNode.context = ctxNamespace; ctxNamespace = nextContext; } // bubble阶段恢复 export function resetNamespaceCtx(vNode: VNode) { - ctxNamespace = vNode.contexts; + ctxNamespace = vNode.context; } export function getNamespaceCtx(): string { @@ -34,7 +34,7 @@ export function getNamespaceCtx(): string { export function setContext(providerVNode: VNode, nextValue: T) { const context: ContextType = providerVNode.type._context; - providerVNode.contexts = context.value; + providerVNode.context = context.value; context.value = nextValue; } @@ -42,7 +42,7 @@ export function setContext(providerVNode: VNode, nextValue: T) { export function resetContext(providerVNode: VNode) { const context: ContextType = providerVNode.type._context; - context.value = providerVNode.contexts; + context.value = providerVNode.context; } // 在局部更新时,恢复父节点的context @@ -51,7 +51,7 @@ export function recoverParentContext(vNode: VNode) { while (parent !== null) { if (parent.tag === ContextProvider) { - parent.contexts = parent.props.value; + parent.context = parent.props.value; } parent = parent.parent; } diff --git a/libs/horizon/src/renderer/vnode/VNode.ts b/libs/horizon/src/renderer/vnode/VNode.ts index 7189db06..bbde565f 100644 --- a/libs/horizon/src/renderer/vnode/VNode.ts +++ b/libs/horizon/src/renderer/vnode/VNode.ts @@ -55,7 +55,7 @@ export class VNode { task: any; // 使用这个变量来记录修改前的值,用于恢复。 - contexts: any; + context: any; // 因为LazyComponent会修改tag和type属性,为了能识别,增加一个属性 isLazyComponent: boolean; @@ -93,7 +93,7 @@ export class VNode { this.stateCallbacks = null; this.state = null; this.oldState = null; - this.contexts = null; + this.context = null; break; case FunctionComponent: this.realNode = null; @@ -112,16 +112,16 @@ export class VNode { this.depContexts = null; this.isDepContextChange = false; this.oldState = null; - this.contexts = null; + this.context = null; break; case DomPortal: this.realNode = null; - this.contexts = null; + this.context = null; break; case DomComponent: this.realNode = null; this.changeList = null; - this.contexts = null; + this.context = null; break; case DomText: this.realNode = null; @@ -137,7 +137,7 @@ export class VNode { }; break; case ContextProvider: - this.contexts = null; + this.context = null; break; case MemoComponent: this.effectList = null;