Match-id-2d3ad46152443e0e465ba7f54dc734e3cf1694af
This commit is contained in:
parent
8c1b44cde9
commit
712b9b42c1
|
@ -17,14 +17,14 @@ let ctxNamespace = '';
|
||||||
export function setNamespaceCtx(vNode: VNode, dom?: Container) {
|
export function setNamespaceCtx(vNode: VNode, dom?: Container) {
|
||||||
const nextContext = getNSCtx(ctxNamespace, vNode.type, dom);
|
const nextContext = getNSCtx(ctxNamespace, vNode.type, dom);
|
||||||
|
|
||||||
vNode.contexts = ctxNamespace;
|
vNode.context = ctxNamespace;
|
||||||
|
|
||||||
ctxNamespace = nextContext;
|
ctxNamespace = nextContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
// bubble阶段恢复
|
// bubble阶段恢复
|
||||||
export function resetNamespaceCtx(vNode: VNode) {
|
export function resetNamespaceCtx(vNode: VNode) {
|
||||||
ctxNamespace = vNode.contexts;
|
ctxNamespace = vNode.context;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getNamespaceCtx(): string {
|
export function getNamespaceCtx(): string {
|
||||||
|
@ -34,7 +34,7 @@ export function getNamespaceCtx(): string {
|
||||||
export function setContext<T>(providerVNode: VNode, nextValue: T) {
|
export function setContext<T>(providerVNode: VNode, nextValue: T) {
|
||||||
const context: ContextType<T> = providerVNode.type._context;
|
const context: ContextType<T> = providerVNode.type._context;
|
||||||
|
|
||||||
providerVNode.contexts = context.value;
|
providerVNode.context = context.value;
|
||||||
|
|
||||||
context.value = nextValue;
|
context.value = nextValue;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ export function setContext<T>(providerVNode: VNode, nextValue: T) {
|
||||||
export function resetContext(providerVNode: VNode) {
|
export function resetContext(providerVNode: VNode) {
|
||||||
const context: ContextType<any> = providerVNode.type._context;
|
const context: ContextType<any> = providerVNode.type._context;
|
||||||
|
|
||||||
context.value = providerVNode.contexts;
|
context.value = providerVNode.context;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 在局部更新时,恢复父节点的context
|
// 在局部更新时,恢复父节点的context
|
||||||
|
@ -51,7 +51,7 @@ export function recoverParentContext(vNode: VNode) {
|
||||||
|
|
||||||
while (parent !== null) {
|
while (parent !== null) {
|
||||||
if (parent.tag === ContextProvider) {
|
if (parent.tag === ContextProvider) {
|
||||||
parent.contexts = parent.props.value;
|
parent.context = parent.props.value;
|
||||||
}
|
}
|
||||||
parent = parent.parent;
|
parent = parent.parent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ export class VNode {
|
||||||
task: any;
|
task: any;
|
||||||
|
|
||||||
// 使用这个变量来记录修改前的值,用于恢复。
|
// 使用这个变量来记录修改前的值,用于恢复。
|
||||||
contexts: any;
|
context: any;
|
||||||
// 因为LazyComponent会修改tag和type属性,为了能识别,增加一个属性
|
// 因为LazyComponent会修改tag和type属性,为了能识别,增加一个属性
|
||||||
isLazyComponent: boolean;
|
isLazyComponent: boolean;
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ export class VNode {
|
||||||
this.stateCallbacks = null;
|
this.stateCallbacks = null;
|
||||||
this.state = null;
|
this.state = null;
|
||||||
this.oldState = null;
|
this.oldState = null;
|
||||||
this.contexts = null;
|
this.context = null;
|
||||||
break;
|
break;
|
||||||
case FunctionComponent:
|
case FunctionComponent:
|
||||||
this.realNode = null;
|
this.realNode = null;
|
||||||
|
@ -112,16 +112,16 @@ export class VNode {
|
||||||
this.depContexts = null;
|
this.depContexts = null;
|
||||||
this.isDepContextChange = false;
|
this.isDepContextChange = false;
|
||||||
this.oldState = null;
|
this.oldState = null;
|
||||||
this.contexts = null;
|
this.context = null;
|
||||||
break;
|
break;
|
||||||
case DomPortal:
|
case DomPortal:
|
||||||
this.realNode = null;
|
this.realNode = null;
|
||||||
this.contexts = null;
|
this.context = null;
|
||||||
break;
|
break;
|
||||||
case DomComponent:
|
case DomComponent:
|
||||||
this.realNode = null;
|
this.realNode = null;
|
||||||
this.changeList = null;
|
this.changeList = null;
|
||||||
this.contexts = null;
|
this.context = null;
|
||||||
break;
|
break;
|
||||||
case DomText:
|
case DomText:
|
||||||
this.realNode = null;
|
this.realNode = null;
|
||||||
|
@ -137,7 +137,7 @@ export class VNode {
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case ContextProvider:
|
case ContextProvider:
|
||||||
this.contexts = null;
|
this.context = null;
|
||||||
break;
|
break;
|
||||||
case MemoComponent:
|
case MemoComponent:
|
||||||
this.effectList = null;
|
this.effectList = null;
|
||||||
|
|
Loading…
Reference in New Issue