diff --git a/libs/horizon/src/external/ChildrenUtil.ts b/libs/horizon/src/external/ChildrenUtil.ts index bb5b51c2..b034107a 100644 --- a/libs/horizon/src/external/ChildrenUtil.ts +++ b/libs/horizon/src/external/ChildrenUtil.ts @@ -70,7 +70,7 @@ function callMapFun(children: any, arr: Array, prefix: string, callback: Fu mappedChild.ref, mappedChild.belongClassVNode, mappedChild.props, - mappedChild._source + mappedChild.src ); } arr.push(mappedChild); diff --git a/libs/horizon/src/external/JSXElement.ts b/libs/horizon/src/external/JSXElement.ts index 6b108461..e842d417 100644 --- a/libs/horizon/src/external/JSXElement.ts +++ b/libs/horizon/src/external/JSXElement.ts @@ -27,7 +27,7 @@ export function JSXElement(type, key, ref, vNode, props, source: Source | null) } function isValidKey(key) { - const keyArray = ['key', 'ref', '__source', '__self']; + const keyArray = ['key', 'ref', '__source']; return !keyArray.includes(key); } @@ -41,8 +41,8 @@ function mergeDefault(sourceObj, defaultObj) { function buildElement(isClone, type, setting, children) { // setting中的值优先级最高,clone情况下从 type 中取值,创建情况下直接赋值为 null - const key = setting && setting.key !== undefined ? String(setting.key) : isClone ? type.key : null; - const ref = setting && setting.ref !== undefined ? setting.ref : isClone ? type.ref : null; + const key = (setting && setting.key !== undefined) ? String(setting.key) : (isClone ? type.key : null); + const ref = (setting && setting.ref !== undefined) ? setting.ref : (isClone ? type.ref : null); const props = isClone ? { ...type.props } : {}; let vNode = isClone ? type.belongClassVNode : getProcessingClassVNode(); diff --git a/libs/horizon/src/renderer/Types.ts b/libs/horizon/src/renderer/Types.ts index c79a81c9..45f76fa9 100644 --- a/libs/horizon/src/renderer/Types.ts +++ b/libs/horizon/src/renderer/Types.ts @@ -12,7 +12,7 @@ export type UseContextHookType = { useContext(context: ContextType): T }; export type JSXElement = { vtype: any; - _source: any; + src: any; type: any; key: any; ref: any; diff --git a/libs/horizon/src/renderer/vnode/VNodeCreator.ts b/libs/horizon/src/renderer/vnode/VNodeCreator.ts index 88ee2928..79496323 100644 --- a/libs/horizon/src/renderer/vnode/VNodeCreator.ts +++ b/libs/horizon/src/renderer/vnode/VNodeCreator.ts @@ -185,12 +185,12 @@ export function createVNode(tag: VNodeTag | string, ...secondArg) { } export function createVNodeFromElement(element: JSXElement): VNode { - const { type, key, props, _source } = element; + const { type, key, props, src } = element; if (type === TYPE_STRICT_MODE || type === TYPE_FRAGMENT || type === TYPE_PROFILER) { return createFragmentVNode(key, props.children); } else { - return createUndeterminedVNode(type, key, props, _source); + return createUndeterminedVNode(type, key, props, src); } }