From 5fa7c0497a7de33d24bccd20a86349889d238f4f Mon Sep 17 00:00:00 2001 From: * <*> Date: Tue, 11 Apr 2023 11:23:03 +0800 Subject: [PATCH 1/6] Match-id-4ccb9ad044168b73b7fc920c04d9fafc9bece593 --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f42fe512..e659a986 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,12 +12,12 @@ - **core**: 增加jsx-dev-runtime文件,给vite使用 ## 0.0.40 (2023-03-08) -- **core**: #103 使用Memo、React.forwardRef包装组件后,defaultProps失效 +- **core**: #103 使用Memo、forwardRef包装组件后,defaultProps失效 - **core**: #104 --max-segment-num的style无法使用 - **core**: 状态管理器的优化 ## 0.0.39 (2023-02-21) -- **core**: #102 使用eview-react组件Dialog时,关闭组件horizon报错,且无法再打开弹框 +- **core**: #102 使用eview组件Dialog时,关闭组件horizon报错,且无法再打开弹框 ## 0.0.38 (2023-02-01) - **core**: 增加flushSync接口 @@ -51,7 +51,7 @@ - **core**: fix 修改IE上报Symbol错误的问题 ## 0.0.23 (2022-09-23) -- **core**: #86 兼容ReactIs API +- **core**: #86 兼容Is API ## 0.0.22 (2022-09-22) - **core**: #83 #75 #72 input支持受控 From ef6fd2888ac71c0f274fb25552ae5ef221f7a342 Mon Sep 17 00:00:00 2001 From: * <*> Date: Wed, 17 May 2023 15:39:26 +0800 Subject: [PATCH 2/6] Match-id-dc2c8508a5e1dec65fe87e6d8a44d2e02af52459 --- libs/horizon/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/horizon/package.json b/libs/horizon/package.json index 5cf8027c..b4640a73 100644 --- a/libs/horizon/package.json +++ b/libs/horizon/package.json @@ -4,7 +4,7 @@ "keywords": [ "horizon" ], - "version": "0.0.45", + "version": "0.0.47", "homepage": "", "bugs": "", "main": "index.js", From 8a9fdd01a63dcfd2ba508b6b581aa78d1a3d1bb5 Mon Sep 17 00:00:00 2001 From: * <*> Date: Wed, 17 May 2023 21:30:53 +0800 Subject: [PATCH 3/6] Match-id-bf925df05da50203ca4baf87357f2a25d21ca829 --- .cloudbuild/test.yml | 2 +- .../src/dom/DOMPropertiesHandler/StyleHandler.ts | 12 ++++++++++++ scripts/__tests__/DomTest/Attribute.test.js | 6 ++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.cloudbuild/test.yml b/.cloudbuild/test.yml index a5c7242f..10f27393 100644 --- a/.cloudbuild/test.yml +++ b/.cloudbuild/test.yml @@ -13,7 +13,7 @@ env: resource: type: docker image: kweecr04.his.huawei.com:80/ecr-build-arm-gzkunpeng/euleros_v2r7spc522_x64_opmt_cs5.0_sz:v5.0 - class: 4U8G + class: 8U16G mode: toolbox cache: - type: workspace diff --git a/libs/horizon/src/dom/DOMPropertiesHandler/StyleHandler.ts b/libs/horizon/src/dom/DOMPropertiesHandler/StyleHandler.ts index 3c3a9a24..e2fca141 100644 --- a/libs/horizon/src/dom/DOMPropertiesHandler/StyleHandler.ts +++ b/libs/horizon/src/dom/DOMPropertiesHandler/StyleHandler.ts @@ -33,6 +33,17 @@ const noUnitCSS = [ 'zoom', ]; +const length = noUnitCSS.length; +for (let i = 0; i < length; i++) { + const cssKey = noUnitCSS[i]; + const attributeKey = cssKey.charAt(0).toUpperCase() + cssKey.slice(1); + + // css 兼容性前缀 webkit: chrome, mo: IE或者Edge, Moz: 火狐 + noUnitCSS.push('Webkit' + attributeKey); + noUnitCSS.push('mo' + attributeKey); + noUnitCSS.push('Moz' + attributeKey); +} + function isNeedUnitCSS(styleName: string) { return !( noUnitCSS.includes(styleName) || @@ -78,6 +89,7 @@ export function setStyles(dom, styles) { if (name.indexOf('--') === 0) { style.setProperty(name, styleVal); } else { + // 使用这种赋值方式,浏览器可以将'WebkitLineClamp', 'backgroundColor'分别识别为'-webkit-line-clamp'和'backgroud-color' style[name] = adjustStyleValue(name, styleVal); } }); diff --git a/scripts/__tests__/DomTest/Attribute.test.js b/scripts/__tests__/DomTest/Attribute.test.js index 90823780..56004668 100755 --- a/scripts/__tests__/DomTest/Attribute.test.js +++ b/scripts/__tests__/DomTest/Attribute.test.js @@ -83,6 +83,12 @@ describe('Dom Attribute', () => { expect(window.getComputedStyle(div).getPropertyValue('height')).toBe('20px'); }); + it('WebkitLineClamp和lineClamp样式不会把数字转换成字符串或者追加"px"', () => { + Horizon.render(
, container); + // 浏览器可以将WebkitLineClamp识别为-webkit-line-clamp,测试框架不可以 + expect(container.querySelector('div').style.WebkitLineClamp).toBe(2); + }); + it('空字符串做属性名', () => { const emptyStringProps = { '': '' }; expect(() => { From 58e1de39576649f8e42a0ffef1c35f34e8af004b Mon Sep 17 00:00:00 2001 From: * <*> Date: Thu, 18 May 2023 21:46:59 +0800 Subject: [PATCH 4/6] Match-id-40ac0e7e6e1927b826730b3937fe6f00c7a4b394 --- CHANGELOG.md | 3 +++ libs/horizon/package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d019e752..bffc742f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.0.48 (2023-05-18) +- **core**: 解决style中属性WebkitLineClamp值被转换成字符串问题 + ## 0.0.45 (2023-05-10) - **core**: 修改belongClassVNode属性为Symbol提升性能 - **core**: 优化内部循环实现,提升性能 diff --git a/libs/horizon/package.json b/libs/horizon/package.json index b4640a73..71fad88d 100644 --- a/libs/horizon/package.json +++ b/libs/horizon/package.json @@ -4,7 +4,7 @@ "keywords": [ "horizon" ], - "version": "0.0.47", + "version": "0.0.48", "homepage": "", "bugs": "", "main": "index.js", From 630cc2ca262661adac31b21f44fc885b0df906ab Mon Sep 17 00:00:00 2001 From: * <*> Date: Fri, 19 May 2023 10:34:15 +0800 Subject: [PATCH 5/6] Match-id-4b079f1ecf2a5cb384aed61f56d8e4485b301702 --- CHANGELOG.md | 3 +++ libs/horizon/package.json | 2 +- libs/horizon/src/dom/DOMOperator.ts | 2 +- libs/horizon/src/dom/validators/ValidateProps.ts | 2 +- libs/horizon/src/renderer/TreeBuilder.ts | 5 +++++ libs/horizon/src/renderer/components/BaseClassComponent.ts | 2 +- 6 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0cf79c9..baecec7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.0.49 (2023-05-19) +- **core**: 解决当组件被销毁,业务若异步(定时器)调用setState修改状态,可能出现路径错误问题。 + ## 0.0.48 (2023-05-18) - **core**: 解决style中属性WebkitLineClamp值被转换成字符串问题 diff --git a/libs/horizon/package.json b/libs/horizon/package.json index 71fad88d..35b506ef 100644 --- a/libs/horizon/package.json +++ b/libs/horizon/package.json @@ -4,7 +4,7 @@ "keywords": [ "horizon" ], - "version": "0.0.48", + "version": "0.0.49", "homepage": "", "bugs": "", "main": "index.js", diff --git a/libs/horizon/src/dom/DOMOperator.ts b/libs/horizon/src/dom/DOMOperator.ts index a7abe22d..f83893e5 100644 --- a/libs/horizon/src/dom/DOMOperator.ts +++ b/libs/horizon/src/dom/DOMOperator.ts @@ -141,7 +141,7 @@ export function newTextDom(text: string, processing: VNode): Text { return textNode; } -// 提交vNode的类型为Component或者Text的更新 +// 提交vNode的类型为DomComponent或者DomText的更新 export function submitDomUpdate(tag: string, vNode: VNode) { const newProps = vNode.props; const element: Element | null = vNode.realNode; diff --git a/libs/horizon/src/dom/validators/ValidateProps.ts b/libs/horizon/src/dom/validators/ValidateProps.ts index d6629b29..f025ce63 100644 --- a/libs/horizon/src/dom/validators/ValidateProps.ts +++ b/libs/horizon/src/dom/validators/ValidateProps.ts @@ -98,7 +98,7 @@ export function validateProps(type, props) { return; } - // 非内置的变迁 + // 非内置的元素 if (!isNativeElement(type, props)) { return; } diff --git a/libs/horizon/src/renderer/TreeBuilder.ts b/libs/horizon/src/renderer/TreeBuilder.ts index eb20b0ef..9798bb8a 100644 --- a/libs/horizon/src/renderer/TreeBuilder.ts +++ b/libs/horizon/src/renderer/TreeBuilder.ts @@ -179,6 +179,11 @@ function isEqualByIndex(idx: number, pathArrays: string[][]) { function getChildByIndex(vNode: VNode, idx: number) { let node = vNode.child; for (let i = 0; i < idx; i++) { + // 场景:当组件被销毁,业务若异步(定时器)调用setState修改状态,可能出现路径错误,此处进行保护。 + if (node == null) { + return null; + } + node = node.next; } return node; diff --git a/libs/horizon/src/renderer/components/BaseClassComponent.ts b/libs/horizon/src/renderer/components/BaseClassComponent.ts index de4ff351..70b09ee4 100644 --- a/libs/horizon/src/renderer/components/BaseClassComponent.ts +++ b/libs/horizon/src/renderer/components/BaseClassComponent.ts @@ -33,7 +33,7 @@ class Component{ setState(state: S, callback?: Callback) { if (isDev) { - console.error('Cant not call `this.setState` in the constructor of class component, it will do nothing'); + console.error('Can not call `this.setState` in the constructor of class component, it will do nothing'); } } } From a4671aa06f21581a23ea294581a1261b96cd03fa Mon Sep 17 00:00:00 2001 From: * <*> Date: Tue, 23 May 2023 21:02:58 +0800 Subject: [PATCH 6/6] Match-id-9ffb3423d9cbe56ad4f381a2e50b90f7caa403ff --- CHANGELOG.md | 3 +++ libs/horizon/package.json | 2 +- libs/horizon/src/external/JSXElement.ts | 8 ++++++++ libs/horizon/src/renderer/vnode/VNode.ts | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index baecec7b..b9010423 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.0.50 (2023-05-23) +- **core**: 解决IE11不兼容Symbol问题 + ## 0.0.49 (2023-05-19) - **core**: 解决当组件被销毁,业务若异步(定时器)调用setState修改状态,可能出现路径错误问题。 diff --git a/libs/horizon/package.json b/libs/horizon/package.json index 35b506ef..286222ac 100644 --- a/libs/horizon/package.json +++ b/libs/horizon/package.json @@ -4,7 +4,7 @@ "keywords": [ "horizon" ], - "version": "0.0.49", + "version": "0.0.50", "homepage": "", "bugs": "", "main": "index.js", diff --git a/libs/horizon/src/external/JSXElement.ts b/libs/horizon/src/external/JSXElement.ts index ccf43079..5ff3db84 100644 --- a/libs/horizon/src/external/JSXElement.ts +++ b/libs/horizon/src/external/JSXElement.ts @@ -40,6 +40,14 @@ export function JSXElement(type, key, ref, vNode, props, source: Source | null) // 所属的class组件,clonedeep jsxElement时需要防止无限循环 [BELONG_CLASS_VNODE_KEY]: vNode, }; + // 兼容IE11不支持Symbol + if (typeof BELONG_CLASS_VNODE_KEY === 'string') { + Object.defineProperty(ele, BELONG_CLASS_VNODE_KEY, { + configurable: false, + enumerable: false, + value: vNode, + }); + } if (isDev) { // 为了test判断两个 JSXElement 对象是否相等时忽略src属性,需要设置src的enumerable为false Object.defineProperty(ele, 'src', { diff --git a/libs/horizon/src/renderer/vnode/VNode.ts b/libs/horizon/src/renderer/vnode/VNode.ts index 4911f887..bc56dee5 100644 --- a/libs/horizon/src/renderer/vnode/VNode.ts +++ b/libs/horizon/src/renderer/vnode/VNode.ts @@ -38,7 +38,7 @@ import type { Hook } from '../hooks/HookType'; import { InitFlag } from './VNodeFlags'; import { Observer } from '../../horizonx/proxy/Observer'; -export const BELONG_CLASS_VNODE_KEY = Symbol('belongClassVNode'); +export const BELONG_CLASS_VNODE_KEY = typeof Symbol === 'function' ? Symbol('belongClassVNode') : 'belongClassVNode'; export class VNode { tag: VNodeTag;