Match-id-1335e3889f5c02b60f5677cb8bb35b2322310d6b

This commit is contained in:
* 2022-01-20 15:59:54 +08:00 committed by *
parent 455bfb4c23
commit ebf980b555
9 changed files with 22 additions and 22 deletions

View File

@ -69,7 +69,7 @@ function isNodeContainsByTargetNode(targetNode, node) {
return false;
}
function isInDocument(dom) {
function isInDocument(dom): any | void {
if (dom && dom.ownerDocument) {
return isNodeContainsByTargetNode(dom.ownerDocument.documentElement, dom);
}

View File

@ -34,12 +34,12 @@ export function watchValueChange(dom) {
// currentVal存储最新值并重写value的setter、getter
let currentVal = String(dom[keyForValue]);
const setFunc = descriptor.set;
const setFunc = descriptor?.set;
Object.defineProperty(dom, keyForValue, {
...descriptor,
set: function(value) {
currentVal = String(value);
setFunc.apply(this, [value]);
setFunc?.apply(this, [value]);
},
});

View File

@ -47,7 +47,6 @@ function mapChildrenToArray(
'Object is invalid as a Horizon child. '
);
default:
return;
}
}

View File

@ -219,7 +219,7 @@ export function tryRenderRoot(treeRoot: VNode) {
}
// 发起更新
export function launchUpdateFromVNode(vNode: VNode): null | void {
export function launchUpdateFromVNode(vNode: VNode): void {
// 检查循环调用
checkLoopingUpdateLimit();
@ -228,7 +228,7 @@ export function launchUpdateFromVNode(vNode: VNode): null | void {
if (treeRoot === null) {
// 可能场景是the componentWillUnmount method 或 useEffect cleanup function 方法中写异步任务并且修改state。
// 因为异步回调的时候root都可能被清除了。
return null;
return;
}
// 保存待刷新的节点

View File

@ -6,7 +6,7 @@ export const isSameType = (vNode: VNode, ele: HorizonElement) => {
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;
// 如果ref是null、function、object直接返回
if (elementRef === null || typeof elementRef === 'function' || typeof elementRef === 'object') {

View File

@ -31,9 +31,9 @@ function useEffect(
}
if (stage === HookStage.Init) {
return useEffectForInit(effectFunc, deps, effectType);
useEffectForInit(effectFunc, deps, effectType);
} else if (stage === HookStage.Update) {
return useEffectForUpdate(effectFunc, deps, effectType);
useEffectForUpdate(effectFunc, deps, effectType);
}
}

View File

@ -30,7 +30,7 @@ function captureLazyComponent(
processing,
lazyComponent,
shouldUpdate,
) {
): any | void {
if (!processing.isCreated) {
// 每次加载lazy都当作mount来处理
processing.isCreated = true;

View File

@ -70,8 +70,8 @@ function callBeforeSubmitLifeCycles(
case TreeRoot: {
const root = vNode.realNode;
clearContainer(root.outerDom);
return;
}
// No Default
}
}
@ -136,8 +136,8 @@ function callAfterSubmitLifeCycles(
vNode.realNode.focus();
}
}
return;
}
//No Default
}
}

View File

@ -144,6 +144,7 @@ export function findDomVNode(vNode: VNode): VNode | null {
if (node.tag === DomComponent || node.tag === DomText) {
return node;
}
return null;
});
}