Match-id-af313b916e0537aca698ab33cb9b377a9669c8cd
This commit is contained in:
parent
f0ffc90fcf
commit
74190969a5
|
@ -11,7 +11,6 @@ import {
|
||||||
} from '../vnode/VNodeTags';
|
} from '../vnode/VNodeTags';
|
||||||
import { getContextChangeCtx, setContextCtx, setNamespaceCtx } from '../ContextSaver';
|
import { getContextChangeCtx, setContextCtx, setNamespaceCtx } from '../ContextSaver';
|
||||||
import { FlagUtils } from '../vnode/VNodeFlags';
|
import { FlagUtils } from '../vnode/VNodeFlags';
|
||||||
import { createChildrenByDiff } from '../diff/nodeDiffComparator';
|
|
||||||
import {onlyUpdateChildVNodes} from '../vnode/VNodeCreator';
|
import {onlyUpdateChildVNodes} from '../vnode/VNodeCreator';
|
||||||
import componentRenders from './index';
|
import componentRenders from './index';
|
||||||
|
|
||||||
|
@ -64,11 +63,6 @@ export function captureVNode(processing: VNode): VNode | null {
|
||||||
return component.captureRender(processing, shouldUpdate);
|
return component.captureRender(processing, shouldUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建孩子节点
|
|
||||||
export function createVNodeChildren(processing: VNode, nextChildren: any) {
|
|
||||||
return createChildrenByDiff(processing, processing.child, nextChildren, !processing.isCreated);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function markRef(processing: VNode) {
|
export function markRef(processing: VNode) {
|
||||||
const ref = processing.ref;
|
const ref = processing.ref;
|
||||||
if ((processing.isCreated && ref !== null) || (!processing.isCreated && processing.oldRef !== ref)) {
|
if ((processing.isCreated && ref !== null) || (!processing.isCreated && processing.oldRef !== ref)) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ import {
|
||||||
markGetSnapshotBeforeUpdate,
|
markGetSnapshotBeforeUpdate,
|
||||||
} from './class/ClassLifeCycleProcessor';
|
} from './class/ClassLifeCycleProcessor';
|
||||||
import { FlagUtils, DidCapture } from '../vnode/VNodeFlags';
|
import { FlagUtils, DidCapture } from '../vnode/VNodeFlags';
|
||||||
import { createVNodeChildren, markRef } from './BaseComponent';
|
import { markRef } from './BaseComponent';
|
||||||
import {
|
import {
|
||||||
createUpdateArray,
|
createUpdateArray,
|
||||||
processUpdates,
|
processUpdates,
|
||||||
|
@ -29,6 +29,7 @@ import {
|
||||||
import { getContextChangeCtx, setContextChangeCtx } from '../ContextSaver';
|
import { getContextChangeCtx, setContextChangeCtx } from '../ContextSaver';
|
||||||
import { setProcessingClassVNode } from '../GlobalVar';
|
import { setProcessingClassVNode } from '../GlobalVar';
|
||||||
import { onlyUpdateChildVNodes } from '../vnode/VNodeCreator';
|
import { onlyUpdateChildVNodes } from '../vnode/VNodeCreator';
|
||||||
|
import { createChildrenByDiff } from '../diff/nodeDiffComparator';
|
||||||
|
|
||||||
// 获取当前节点的context
|
// 获取当前节点的context
|
||||||
export function getCurrentContext(clazz, processing: VNode) {
|
export function getCurrentContext(clazz, processing: VNode) {
|
||||||
|
@ -80,7 +81,7 @@ function createChildren(clazz: any, processing: VNode) {
|
||||||
? null
|
? null
|
||||||
: inst.render();
|
: inst.render();
|
||||||
|
|
||||||
processing.child = createVNodeChildren(processing, newElements);
|
processing.child = createChildrenByDiff(processing, processing.child, newElements, !processing.isCreated);
|
||||||
return processing.child;
|
return processing.child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {resetDepContexts} from '../components/context/Context';
|
||||||
import {getOldContext} from '../components/context/CompatibleContext';
|
import {getOldContext} from '../components/context/CompatibleContext';
|
||||||
import {FlagUtils} from '../vnode/VNodeFlags';
|
import {FlagUtils} from '../vnode/VNodeFlags';
|
||||||
import {exeFunctionHook} from '../hooks/HookMain';
|
import {exeFunctionHook} from '../hooks/HookMain';
|
||||||
import {createVNodeChildren} from './BaseComponent';
|
import { createChildrenByDiff } from '../diff/nodeDiffComparator';
|
||||||
|
|
||||||
function captureIndeterminateComponent(
|
function captureIndeterminateComponent(
|
||||||
processing: VNode,
|
processing: VNode,
|
||||||
|
@ -25,7 +25,7 @@ function captureIndeterminateComponent(
|
||||||
const newElements = exeFunctionHook(funcComp, props, context, processing);
|
const newElements = exeFunctionHook(funcComp, props, context, processing);
|
||||||
|
|
||||||
processing.tag = FunctionComponent;
|
processing.tag = FunctionComponent;
|
||||||
processing.child = createVNodeChildren(processing, newElements);
|
processing.child = createChildrenByDiff(processing, processing.child, newElements, !processing.isCreated);
|
||||||
return processing.child;
|
return processing.child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import type {VNode, ContextType} from '../Types';
|
import type {VNode, ContextType} from '../Types';
|
||||||
|
|
||||||
import {resetDepContexts, getNewContext} from '../components/context/Context';
|
import {resetDepContexts, getNewContext} from '../components/context/Context';
|
||||||
import {createVNodeChildren} from './BaseComponent';
|
import { createChildrenByDiff } from '../diff/nodeDiffComparator';
|
||||||
|
|
||||||
function captureContextConsumer(processing: VNode) {
|
function captureContextConsumer(processing: VNode) {
|
||||||
const context: ContextType<any> = processing.type;
|
const context: ContextType<any> = processing.type;
|
||||||
|
@ -12,7 +12,7 @@ function captureContextConsumer(processing: VNode) {
|
||||||
const contextVal = getNewContext(processing, context);
|
const contextVal = getNewContext(processing, context);
|
||||||
const newChildren = renderFunc(contextVal);
|
const newChildren = renderFunc(contextVal);
|
||||||
|
|
||||||
processing.child = createVNodeChildren(processing, newChildren);
|
processing.child = createChildrenByDiff(processing, processing.child, newChildren, !processing.isCreated);
|
||||||
return processing.child;
|
return processing.child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import type { VNode, ContextType, ProviderType } from '../Types';
|
import type { VNode, ContextType, ProviderType } from '../Types';
|
||||||
|
|
||||||
import {createVNodeChildren} from './BaseComponent';
|
|
||||||
import { isSame } from '../utils/compare';
|
import { isSame } from '../utils/compare';
|
||||||
import { ClassComponent, ContextProvider } from '../vnode/VNodeTags';
|
import { ClassComponent, ContextProvider } from '../vnode/VNodeTags';
|
||||||
import { pushForceUpdate } from '../UpdateHandler';
|
import { pushForceUpdate } from '../UpdateHandler';
|
||||||
|
@ -9,10 +8,11 @@ import {
|
||||||
resetContextCtx,
|
resetContextCtx,
|
||||||
setContextCtx,
|
setContextCtx,
|
||||||
} from '../ContextSaver';
|
} from '../ContextSaver';
|
||||||
import {getFirstChild, travelVNodeTree} from '../vnode/VNodeUtils';
|
import { travelVNodeTree } from '../vnode/VNodeUtils';
|
||||||
import { launchUpdateFromVNode } from '../TreeBuilder';
|
import { launchUpdateFromVNode } from '../TreeBuilder';
|
||||||
import { onlyUpdateChildVNodes } from '../vnode/VNodeCreator';
|
import { onlyUpdateChildVNodes } from '../vnode/VNodeCreator';
|
||||||
import { setParentsChildShouldUpdate } from '../vnode/VNodeShouldUpdate';
|
import { setParentsChildShouldUpdate } from '../vnode/VNodeShouldUpdate';
|
||||||
|
import { createChildrenByDiff } from '../diff/nodeDiffComparator';
|
||||||
|
|
||||||
// 从依赖中找到匹配context的VNode
|
// 从依赖中找到匹配context的VNode
|
||||||
function matchDependencies(depContexts, context, vNode): boolean {
|
function matchDependencies(depContexts, context, vNode): boolean {
|
||||||
|
@ -92,7 +92,7 @@ function captureContextProvider(processing: VNode): VNode | null {
|
||||||
}
|
}
|
||||||
|
|
||||||
const newElements = newProps.children;
|
const newElements = newProps.children;
|
||||||
processing.child = createVNodeChildren(processing, newElements);
|
processing.child = createChildrenByDiff(processing, processing.child, newElements, !processing.isCreated);
|
||||||
return processing.child;
|
return processing.child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,10 @@ import {
|
||||||
isTextChild,
|
isTextChild,
|
||||||
} from '../../dom/DOMOperator';
|
} from '../../dom/DOMOperator';
|
||||||
import { FlagUtils } from '../vnode/VNodeFlags';
|
import { FlagUtils } from '../vnode/VNodeFlags';
|
||||||
import { createVNodeChildren, markRef } from './BaseComponent';
|
import { markRef } from './BaseComponent';
|
||||||
import { DomComponent, DomPortal, DomText } from '../vnode/VNodeTags';
|
import { DomComponent, DomPortal, DomText } from '../vnode/VNodeTags';
|
||||||
import { travelVNodeTree } from '../vnode/VNodeUtils';
|
import { travelVNodeTree } from '../vnode/VNodeUtils';
|
||||||
|
import { createChildrenByDiff } from '../diff/nodeDiffComparator';
|
||||||
|
|
||||||
function updateDom(
|
function updateDom(
|
||||||
processing: VNode,
|
processing: VNode,
|
||||||
|
@ -123,7 +124,7 @@ function captureDomComponent(processing: VNode): VNode | null {
|
||||||
}
|
}
|
||||||
|
|
||||||
markRef(processing);
|
markRef(processing);
|
||||||
processing.child = createVNodeChildren(processing, nextChildren);
|
processing.child = createChildrenByDiff(processing, processing.child, nextChildren, !processing.isCreated);
|
||||||
return processing.child;
|
return processing.child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import type { VNode } from '../Types';
|
import type { VNode } from '../Types';
|
||||||
import { resetNamespaceCtx, setNamespaceCtx } from '../ContextSaver';
|
import { resetNamespaceCtx, setNamespaceCtx } from '../ContextSaver';
|
||||||
import { createChildrenByDiff } from '../diff/nodeDiffComparator';
|
import { createChildrenByDiff } from '../diff/nodeDiffComparator';
|
||||||
import { createVNodeChildren } from './BaseComponent';
|
|
||||||
import { prePortal } from '../../dom/DOMOperator';
|
import { prePortal } from '../../dom/DOMOperator';
|
||||||
|
|
||||||
export function bubbleRender(processing: VNode) {
|
export function bubbleRender(processing: VNode) {
|
||||||
|
@ -19,7 +18,7 @@ function capturePortalComponent(processing: VNode) {
|
||||||
if (processing.isCreated) {
|
if (processing.isCreated) {
|
||||||
processing.child = createChildrenByDiff(processing, null, newElements, true);
|
processing.child = createChildrenByDiff(processing, null, newElements, true);
|
||||||
} else {
|
} else {
|
||||||
processing.child = createVNodeChildren(processing, newElements);
|
processing.child = createChildrenByDiff(processing, processing.child, newElements, !processing.isCreated);
|
||||||
}
|
}
|
||||||
return processing.child;
|
return processing.child;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import type {VNode} from '../Types';
|
import type {VNode} from '../Types';
|
||||||
import {createVNodeChildren} from './BaseComponent';
|
import { createChildrenByDiff } from '../diff/nodeDiffComparator';
|
||||||
|
|
||||||
export function bubbleRender() {}
|
export function bubbleRender() {}
|
||||||
|
|
||||||
function captureFragment(processing: VNode) {
|
function captureFragment(processing: VNode) {
|
||||||
const newElement = processing.props;
|
const newElement = processing.props;
|
||||||
processing.child = createVNodeChildren(processing, newElement);
|
processing.child = createChildrenByDiff(processing, processing.child, newElement, !processing.isCreated);
|
||||||
return processing.child;
|
return processing.child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,11 @@ import {mergeDefaultProps} from './LazyComponent';
|
||||||
import {getOldContext} from '../components/context/CompatibleContext';
|
import {getOldContext} from '../components/context/CompatibleContext';
|
||||||
import {resetDepContexts} from '../components/context/Context';
|
import {resetDepContexts} from '../components/context/Context';
|
||||||
import {exeFunctionHook} from '../hooks/HookMain';
|
import {exeFunctionHook} from '../hooks/HookMain';
|
||||||
import {createVNodeChildren} from './BaseComponent';
|
|
||||||
import {ForwardRef} from '../vnode/VNodeTags';
|
import {ForwardRef} from '../vnode/VNodeTags';
|
||||||
import {FlagUtils, Update} from '../vnode/VNodeFlags';
|
import {FlagUtils, Update} from '../vnode/VNodeFlags';
|
||||||
import {getContextChangeCtx} from '../ContextSaver';
|
import {getContextChangeCtx} from '../ContextSaver';
|
||||||
import {onlyUpdateChildVNodes} from '../vnode/VNodeCreator';
|
import {onlyUpdateChildVNodes} from '../vnode/VNodeCreator';
|
||||||
|
import { createChildrenByDiff } from '../diff/nodeDiffComparator';
|
||||||
|
|
||||||
// 在useState, useReducer的时候,会触发state变化
|
// 在useState, useReducer的时候,会触发state变化
|
||||||
let stateChange = false;
|
let stateChange = false;
|
||||||
|
@ -79,7 +79,7 @@ export function captureFunctionComponent(
|
||||||
return onlyUpdateChildVNodes(processing);
|
return onlyUpdateChildVNodes(processing);
|
||||||
}
|
}
|
||||||
|
|
||||||
processing.child = createVNodeChildren(processing, newElements);
|
processing.child = createChildrenByDiff(processing, processing.child, newElements, !processing.isCreated);
|
||||||
return processing.child;
|
return processing.child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import type {VNode} from '../Types';
|
import type {VNode} from '../Types';
|
||||||
import {throwIfTrue} from '../utils/throwIfTrue';
|
import {throwIfTrue} from '../utils/throwIfTrue';
|
||||||
import {processUpdates} from '../UpdateHandler';
|
import {processUpdates} from '../UpdateHandler';
|
||||||
import {createVNodeChildren} from './BaseComponent';
|
|
||||||
import {resetNamespaceCtx, setNamespaceCtx} from '../ContextSaver';
|
import {resetNamespaceCtx, setNamespaceCtx} from '../ContextSaver';
|
||||||
import {resetOldCtx} from '../components/context/CompatibleContext';
|
import {resetOldCtx} from '../components/context/CompatibleContext';
|
||||||
import {onlyUpdateChildVNodes} from '../vnode/VNodeCreator';
|
import {onlyUpdateChildVNodes} from '../vnode/VNodeCreator';
|
||||||
|
import { createChildrenByDiff } from '../diff/nodeDiffComparator';
|
||||||
|
|
||||||
export function bubbleRender(processing: VNode) {
|
export function bubbleRender(processing: VNode) {
|
||||||
resetNamespaceCtx(processing);
|
resetNamespaceCtx(processing);
|
||||||
|
@ -33,7 +33,7 @@ function updateTreeRoot(processing) {
|
||||||
if (newElement === oldElement) {
|
if (newElement === oldElement) {
|
||||||
return onlyUpdateChildVNodes(processing);
|
return onlyUpdateChildVNodes(processing);
|
||||||
}
|
}
|
||||||
processing.child = createVNodeChildren(processing, newElement);
|
processing.child = createChildrenByDiff(processing, processing.child, newElement, !processing.isCreated);
|
||||||
return processing.child;
|
return processing.child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue