Match-id-da82a2aa9908dd57e3cfbc3ee740347081aca5d6
This commit is contained in:
parent
ba22cc3bf7
commit
02aad2cad0
|
@ -18,11 +18,6 @@ export enum UpdateState {
|
|||
Error = 'Error',
|
||||
}
|
||||
|
||||
// 初始化更新数组
|
||||
export function createUpdateArray(vNode: VNode): void {
|
||||
vNode.updates = []; // 新产生的update会加入这个数组
|
||||
}
|
||||
|
||||
// 创建update对象
|
||||
export function newUpdate(): Update {
|
||||
return {
|
||||
|
@ -35,8 +30,11 @@ export function newUpdate(): Update {
|
|||
// 将update对象加入updates
|
||||
export function pushUpdate(vNode: VNode, update: Update) {
|
||||
const updates = vNode.updates;
|
||||
|
||||
updates?.push(update);
|
||||
if (updates !== null) {
|
||||
updates.push(update);
|
||||
} else {
|
||||
vNode.updates = [update];
|
||||
}
|
||||
}
|
||||
|
||||
// 根据update获取新的state
|
||||
|
@ -98,12 +96,14 @@ export function processUpdates(vNode: VNode, inst: any, props: any): void {
|
|||
const updates: Updates = vNode.updates;
|
||||
vNode.isForceUpdate = false;
|
||||
|
||||
const toProcessUpdates = [...updates];
|
||||
updates.length = 0;
|
||||
|
||||
if (toProcessUpdates.length) {
|
||||
calcUpdates(vNode, props, inst, toProcessUpdates);
|
||||
if (updates !== null) {
|
||||
const toProcessUpdates = [...updates];
|
||||
updates.length = 0;
|
||||
if (toProcessUpdates.length) {
|
||||
calcUpdates(vNode, props, inst, toProcessUpdates);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export function pushForceUpdate(vNode: VNode) {
|
||||
|
|
|
@ -23,7 +23,6 @@ import {
|
|||
import { FlagUtils, DidCapture } from '../vnode/VNodeFlags';
|
||||
import { markRef } from './BaseComponent';
|
||||
import {
|
||||
createUpdateArray,
|
||||
processUpdates,
|
||||
} from '../UpdateHandler';
|
||||
import { getContextChangeCtx, setContextChangeCtx } from '../ContextSaver';
|
||||
|
@ -55,7 +54,6 @@ function mountInstance(clazz, processing: VNode, nextProps: object) {
|
|||
inst.context = getCurrentContext(clazz, processing);
|
||||
inst.refs = {};
|
||||
|
||||
createUpdateArray(processing);
|
||||
processUpdates(processing, inst, nextProps);
|
||||
inst.state = processing.state;
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ export function bubbleRender(processing: VNode) {
|
|||
}
|
||||
}
|
||||
|
||||
function captureDomComponent(processing: VNode): VNode | null {
|
||||
export function captureRender(processing: VNode): VNode | null {
|
||||
setNamespaceCtx(processing);
|
||||
|
||||
const type = processing.type;
|
||||
|
@ -127,7 +127,3 @@ function captureDomComponent(processing: VNode): VNode | null {
|
|||
processing.child = createChildrenByDiff(processing, processing.child, nextChildren, !processing.isCreated);
|
||||
return processing.child;
|
||||
}
|
||||
|
||||
export function captureRender(processing: VNode): VNode | null {
|
||||
return captureDomComponent(processing);
|
||||
}
|
||||
|
|
|
@ -138,6 +138,7 @@ export class VNode {
|
|||
this.stateCallbacks = null;
|
||||
this.isLazyComponent = true;
|
||||
this.lazyType = null;
|
||||
this.updates = null;
|
||||
break;
|
||||
case Fragment:
|
||||
break;
|
||||
|
|
|
@ -16,7 +16,6 @@ import {
|
|||
MemoComponent,
|
||||
SuspenseComponent,
|
||||
} from './VNodeTags';
|
||||
import { createUpdateArray } from '../UpdateHandler';
|
||||
import {
|
||||
TYPE_CONTEXT,
|
||||
TYPE_FORWARD_REF, TYPE_FRAGMENT,
|
||||
|
@ -137,7 +136,7 @@ export function createUndeterminedVNode(type, key, props) {
|
|||
export function createTreeRootVNode(container) {
|
||||
const vNode = newVirtualNode(TreeRoot, null, null, container);
|
||||
vNode.path += 0;
|
||||
createUpdateArray(vNode);
|
||||
vNode.updates = [];
|
||||
return vNode;
|
||||
}
|
||||
|
||||
|
@ -150,7 +149,7 @@ export function createVNode(tag: VNodeTag | string, ...secondArg) {
|
|||
vNode = newVirtualNode(TreeRoot, null, null, secondArg[0]);
|
||||
vNode.path += 0;
|
||||
|
||||
createUpdateArray(vNode);
|
||||
vNode.updates = [];
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue