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