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