Match-id-4c9c59cc69070aa1cbf35f483bb4d5b06f4a0aa1
This commit is contained in:
commit
72ab41dcd2
|
@ -73,6 +73,7 @@ function isInDocument(dom) {
|
||||||
if (dom && dom.ownerDocument) {
|
if (dom && dom.ownerDocument) {
|
||||||
return isNodeContainsByTargetNode(dom.ownerDocument.documentElement, dom);
|
return isNodeContainsByTargetNode(dom.ownerDocument.documentElement, dom);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 判断一个标签是否有设置选择范围的能力
|
// 判断一个标签是否有设置选择范围的能力
|
||||||
|
|
|
@ -34,12 +34,12 @@ export function watchValueChange(dom) {
|
||||||
// currentVal存储最新值,并重写value的setter、getter
|
// currentVal存储最新值,并重写value的setter、getter
|
||||||
let currentVal = String(dom[keyForValue]);
|
let currentVal = String(dom[keyForValue]);
|
||||||
|
|
||||||
const setFunc = descriptor.set;
|
const setFunc = descriptor?.set;
|
||||||
Object.defineProperty(dom, keyForValue, {
|
Object.defineProperty(dom, keyForValue, {
|
||||||
...descriptor,
|
...descriptor,
|
||||||
set: function (value) {
|
set: function(value) {
|
||||||
currentVal = String(value);
|
currentVal = String(value);
|
||||||
setFunc.apply(this, [value]);
|
setFunc?.apply(this, [value]);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,8 @@ function mapChildrenToArray(
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Object is invalid as a Horizon child. '
|
'Object is invalid as a Horizon child. '
|
||||||
);
|
);
|
||||||
default:
|
|
||||||
return;
|
// No Default
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -219,7 +219,7 @@ export function tryRenderRoot(treeRoot: VNode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发起更新
|
// 发起更新
|
||||||
export function launchUpdateFromVNode(vNode: VNode): null | void {
|
export function launchUpdateFromVNode(vNode: VNode) {
|
||||||
// 检查循环调用
|
// 检查循环调用
|
||||||
checkLoopingUpdateLimit();
|
checkLoopingUpdateLimit();
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ export function launchUpdateFromVNode(vNode: VNode): null | void {
|
||||||
if (treeRoot === null) {
|
if (treeRoot === null) {
|
||||||
// 可能场景是:the componentWillUnmount method 或 useEffect cleanup function 方法中写异步任务,并且修改state。
|
// 可能场景是:the componentWillUnmount method 或 useEffect cleanup function 方法中写异步任务,并且修改state。
|
||||||
// 因为异步回调的时候root都可能被清除了。
|
// 因为异步回调的时候root都可能被清除了。
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保存待刷新的节点
|
// 保存待刷新的节点
|
||||||
|
|
|
@ -6,7 +6,7 @@ export const isSameType = (vNode: VNode, ele: HorizonElement) => {
|
||||||
return vNode.type === ele.type || (vNode.isLazyComponent && vNode.lazyType === ele.type);
|
return vNode.type === ele.type || (vNode.isLazyComponent && vNode.lazyType === ele.type);
|
||||||
};
|
};
|
||||||
|
|
||||||
export function createRef(element: HorizonElement) {
|
export function createRef(element: HorizonElement): any | void {
|
||||||
const elementRef = element.ref;
|
const elementRef = element.ref;
|
||||||
// 如果ref是null、function、object,直接返回
|
// 如果ref是null、function、object,直接返回
|
||||||
if (elementRef === null || typeof elementRef === 'function' || typeof elementRef === 'object') {
|
if (elementRef === null || typeof elementRef === 'function' || typeof elementRef === 'object') {
|
||||||
|
|
|
@ -31,9 +31,9 @@ function useEffect(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stage === HookStage.Init) {
|
if (stage === HookStage.Init) {
|
||||||
return useEffectForInit(effectFunc, deps, effectType);
|
useEffectForInit(effectFunc, deps, effectType);
|
||||||
} else if (stage === HookStage.Update) {
|
} else if (stage === HookStage.Update) {
|
||||||
return useEffectForUpdate(effectFunc, deps, effectType);
|
useEffectForUpdate(effectFunc, deps, effectType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
import type {VNode} from '../Types';
|
import type { VNode } from '../Types';
|
||||||
|
|
||||||
import {FlagUtils} from '../vnode/VNodeFlags';
|
import { FlagUtils } from '../vnode/VNodeFlags';
|
||||||
import {getLazyVNodeTag} from '../vnode/VNodeCreator';
|
import { getLazyVNodeTag } from '../vnode/VNodeCreator';
|
||||||
import {
|
import {
|
||||||
ClassComponent,
|
ClassComponent,
|
||||||
ForwardRef,
|
ForwardRef,
|
||||||
FunctionComponent,
|
FunctionComponent,
|
||||||
MemoComponent,
|
MemoComponent,
|
||||||
} from '../vnode/VNodeTags';
|
} from '../vnode/VNodeTags';
|
||||||
import {throwIfTrue} from '../utils/throwIfTrue';
|
import { throwIfTrue } from '../utils/throwIfTrue';
|
||||||
import {captureFunctionComponent} from './FunctionComponent';
|
import { captureFunctionComponent } from './FunctionComponent';
|
||||||
import {captureClassComponent} from './ClassComponent';
|
import { captureClassComponent } from './ClassComponent';
|
||||||
import {captureMemoComponent} from './MemoComponent';
|
import { captureMemoComponent } from './MemoComponent';
|
||||||
|
|
||||||
export function captureRender(processing: VNode, shouldUpdate: boolean): VNode | null {
|
export function captureRender(processing: VNode, shouldUpdate: boolean): VNode | null {
|
||||||
return captureLazyComponent(processing, processing.type, shouldUpdate);
|
return captureLazyComponent(processing, processing.type, shouldUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function bubbleRender() {}
|
export function bubbleRender() { }
|
||||||
|
|
||||||
const LazyRendererMap = {
|
const LazyRendererMap = {
|
||||||
[FunctionComponent]: captureFunctionComponent,
|
[FunctionComponent]: captureFunctionComponent,
|
||||||
|
@ -64,12 +64,13 @@ function captureLazyComponent(
|
||||||
Component,
|
Component,
|
||||||
'',
|
'',
|
||||||
);
|
);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function mergeDefaultProps(Component: any, props: object): object {
|
export function mergeDefaultProps(Component: any, props: object): object {
|
||||||
if (Component && Component.defaultProps) {
|
if (Component && Component.defaultProps) {
|
||||||
const clonedProps = {...props};
|
const clonedProps = { ...props };
|
||||||
const defaultProps = Component.defaultProps;
|
const defaultProps = Component.defaultProps;
|
||||||
Object.keys(defaultProps).forEach(key => {
|
Object.keys(defaultProps).forEach(key => {
|
||||||
if (clonedProps[key] === undefined) {
|
if (clonedProps[key] === undefined) {
|
||||||
|
|
|
@ -70,8 +70,9 @@ function callBeforeSubmitLifeCycles(
|
||||||
case TreeRoot: {
|
case TreeRoot: {
|
||||||
const root = vNode.realNode;
|
const root = vNode.realNode;
|
||||||
clearContainer(root.outerDom);
|
clearContainer(root.outerDom);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No Default
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,8 +137,9 @@ function callAfterSubmitLifeCycles(
|
||||||
vNode.realNode.focus();
|
vNode.realNode.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No Default
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,6 +144,7 @@ export function findDomVNode(vNode: VNode): VNode | null {
|
||||||
if (node.tag === DomComponent || node.tag === DomText) {
|
if (node.tag === DomComponent || node.tag === DomText) {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue