Match-id-470122e11f1af7f936f3b0991fd467d8fd693eda
This commit is contained in:
parent
a4c685d1b1
commit
f3c0cf9a05
|
@ -1,3 +1,7 @@
|
||||||
|
## 0.0.34 (2023-01-11)
|
||||||
|
- **core**: #95 新增jsx接口
|
||||||
|
- **core**: #96 #97 fix testing-library 的UT错误
|
||||||
|
|
||||||
## 0.0.33 (2023-01-11)
|
## 0.0.33 (2023-01-11)
|
||||||
- **horizonX-devtool**: 修复IE中报错
|
- **horizonX-devtool**: 修复IE中报错
|
||||||
|
|
||||||
|
|
|
@ -19,3 +19,4 @@
|
||||||
declare var isDev: boolean;
|
declare var isDev: boolean;
|
||||||
declare var isTest: boolean;
|
declare var isTest: boolean;
|
||||||
declare const __VERSION__: string;
|
declare const __VERSION__: string;
|
||||||
|
declare var setImmediate: Function;
|
||||||
|
|
|
@ -42,9 +42,6 @@ import {
|
||||||
useState,
|
useState,
|
||||||
useDebugValue,
|
useDebugValue,
|
||||||
} from './src/renderer/hooks/HookExternal';
|
} from './src/renderer/hooks/HookExternal';
|
||||||
import { asyncUpdates } from './src/renderer/TreeBuilder';
|
|
||||||
import { callRenderQueueImmediate } from './src/renderer/taskExecutor/RenderQueue';
|
|
||||||
import { runAsyncEffects } from './src/renderer/submit/HookEffectHandler';
|
|
||||||
import {
|
import {
|
||||||
isContextProvider,
|
isContextProvider,
|
||||||
isContextConsumer,
|
isContextConsumer,
|
||||||
|
@ -59,16 +56,7 @@ import {
|
||||||
import { createStore, useStore, clearStore } from './src/horizonx/store/StoreHandler';
|
import { createStore, useStore, clearStore } from './src/horizonx/store/StoreHandler';
|
||||||
import * as reduxAdapter from './src/horizonx/adapters/redux';
|
import * as reduxAdapter from './src/horizonx/adapters/redux';
|
||||||
import { watch } from './src/horizonx/proxy/watch';
|
import { watch } from './src/horizonx/proxy/watch';
|
||||||
|
import { act } from './src/external/TestUtil';
|
||||||
// act用于测试,作用是:如果fun触发了刷新(包含了异步刷新),可以保证在act后面的代码是在刷新完成后才执行。
|
|
||||||
const act = fun => {
|
|
||||||
asyncUpdates(fun);
|
|
||||||
callRenderQueueImmediate();
|
|
||||||
runAsyncEffects();
|
|
||||||
|
|
||||||
// 兼容返回Promise
|
|
||||||
return Promise.resolve();
|
|
||||||
};
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
render,
|
render,
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"horizon"
|
"horizon"
|
||||||
],
|
],
|
||||||
"version": "0.0.33",
|
"version": "0.0.34",
|
||||||
"homepage": "",
|
"homepage": "",
|
||||||
"bugs": "",
|
"bugs": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
|
|
@ -25,10 +25,10 @@ import { Source } from '../renderer/Types';
|
||||||
* props 其他常规属性
|
* props 其他常规属性
|
||||||
*/
|
*/
|
||||||
export function JSXElement(type, key, ref, vNode, props, source: Source | null) {
|
export function JSXElement(type, key, ref, vNode, props, source: Source | null) {
|
||||||
return {
|
const ele = {
|
||||||
// 元素标识符
|
// 元素标识符
|
||||||
vtype: TYPE_COMMON_ELEMENT,
|
vtype: TYPE_COMMON_ELEMENT,
|
||||||
src: isDev ? source : null,
|
src: null,
|
||||||
|
|
||||||
// 属于元素的内置属性
|
// 属于元素的内置属性
|
||||||
type: type,
|
type: type,
|
||||||
|
@ -39,6 +39,18 @@ export function JSXElement(type, key, ref, vNode, props, source: Source | null)
|
||||||
// 所属的class组件
|
// 所属的class组件
|
||||||
belongClassVNode: vNode,
|
belongClassVNode: vNode,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (isDev) {
|
||||||
|
// 为了test判断两个JSXElement对象是否相等时忽略src属性,需要设置src的enumerable为false
|
||||||
|
Object.defineProperty(ele, 'src', {
|
||||||
|
configurable: false,
|
||||||
|
enumerable: false,
|
||||||
|
writable: false,
|
||||||
|
value: source,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return ele;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isValidKey(key) {
|
function isValidKey(key) {
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Huawei Technologies Co.,Ltd.
|
||||||
|
*
|
||||||
|
* openGauss is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
* You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
*
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import {asyncUpdates} from '../renderer/TreeBuilder';
|
||||||
|
import {callRenderQueueImmediate} from '../renderer/taskExecutor/RenderQueue';
|
||||||
|
import {runAsyncEffects} from '../renderer/submit/HookEffectHandler';
|
||||||
|
import {isPromise} from '../renderer/ErrorHandler';
|
||||||
|
|
||||||
|
// act用于测试,作用是:如果fun触发了刷新(包含了异步刷新),可以保证在act后面的代码是在刷新完成后才执行。
|
||||||
|
function act(fun) {
|
||||||
|
const funRet = asyncUpdates(fun);
|
||||||
|
|
||||||
|
callRenderQueueImmediate();
|
||||||
|
runAsyncEffects();
|
||||||
|
// effects可能产生刷新任务,这里再执行一次
|
||||||
|
callRenderQueueImmediate();
|
||||||
|
|
||||||
|
// 如果fun返回的是Promise
|
||||||
|
if (isPromise(funRet)) {
|
||||||
|
// testing-library会返回Promise
|
||||||
|
return {
|
||||||
|
then(resolve, reject) {
|
||||||
|
funRet.then(
|
||||||
|
() => {
|
||||||
|
if (typeof setImmediate === 'function') {
|
||||||
|
// 通过setImmediate回调,用于等待业务的setTimeout完成
|
||||||
|
setImmediate(() => {
|
||||||
|
callRenderQueueImmediate();
|
||||||
|
runAsyncEffects();
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
callRenderQueueImmediate();
|
||||||
|
runAsyncEffects();
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
err => {
|
||||||
|
reject(err);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
then(resolve) {
|
||||||
|
resolve();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
act
|
||||||
|
}
|
|
@ -72,7 +72,7 @@ function createClassErrorUpdate(vNode: VNode, error: any): Update {
|
||||||
}
|
}
|
||||||
return update;
|
return update;
|
||||||
}
|
}
|
||||||
function isPromise(error: any): error is PromiseType<any> {
|
export function isPromise(error: any): error is PromiseType<any> {
|
||||||
return error !== null && typeof error === 'object' && typeof error.then === 'function';
|
return error !== null && typeof error === 'object' && typeof error.then === 'function';
|
||||||
}
|
}
|
||||||
// 处理capture和bubble阶段抛出的错误
|
// 处理capture和bubble阶段抛出的错误
|
||||||
|
|
Loading…
Reference in New Issue