diff --git a/.cloudbuild/build.yml b/.cloudbuild/build.yml
index b6fcaac9..905877bf 100644
--- a/.cloudbuild/build.yml
+++ b/.cloudbuild/build.yml
@@ -8,15 +8,13 @@ notifications:
buildspace:
log_collect:
- config/CI/build/logs
- fixed: true
+ fixed: false
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
mode: toolbox
- cache:
- - type: workspace
steps:
PRE_BUILD:
- checkout:
@@ -34,4 +32,11 @@ steps:
yarn
yarn run test
yarn run build
- node .cloudbuild/release.js
+ sh .cloudbuild/release.sh
+ enhance:
+ - feature: md5_source_tracement
+ build_tools: [npm]
+ check:
+ auto: true
+ buildcheck: true
+ mode: sync
diff --git a/.cloudbuild/release.js b/.cloudbuild/release.js
deleted file mode 100644
index be212829..00000000
--- a/.cloudbuild/release.js
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
- */
-
-const fs = require('fs');
-const path = require('path');
-const childProcess = require('child_process');
-
-const version = process.env.releaseVersion;
-const DIST_PATH = path.resolve(__dirname, '../build/horizon');
-
-const NPMRC = `registry=https://cmc.centralrepo.rnd.huawei.com/npm
-@cloudsop:registry=https://cmc.centralrepo.rnd.huawei.com/artifactory/product_npm
-_auth = Y2xvdWRzb3BhcnRpZmFjdG9yeTpDbG91ZHNvcDY2NiEhIQ
-always-auth = true
-email = cloudsop@huawei.com
-`;
-if (!version) {
- process.exit();
-}
-if (!/\d+\.\d+\.\d+/.test(version)) {
- console.log('请输入正确版本号');
- process.exit();
-}
-
-const exec = (cmd, cwd) => {
- return new Promise((resolve, reject) => {
- childProcess.exec(
- cmd,
- {
- cwd,
- },
- function (error, stdout, stderr) {
- if (error) {
- error && console.log(`Error: ${error}`);
- reject(error);
- } else {
- stdout && console.log(`STDOUT: ${stdout}`);
- resolve(stdout);
- }
- }
- );
- });
-};
-
-const main = async () => {
- try {
- console.log(`==== Horizon Upgrade ${version} ====`);
- await exec(`npm version ${version}`, DIST_PATH);
- fs.writeFileSync(path.resolve(DIST_PATH, '.npmrc'), NPMRC);
-
- console.log('==== Publish new version====');
- await exec('npm publish', DIST_PATH);
- process.exit();
- } catch (err) {
- console.error(err);
- process.exit(1);
- }
-};
-main();
diff --git a/.cloudbuild/release.sh b/.cloudbuild/release.sh
new file mode 100644
index 00000000..ec87ddab
--- /dev/null
+++ b/.cloudbuild/release.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# 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.
+#
+if [ -n "${releaseVersion}" ] ; then
+ echo "==== Horizon Upgrade ${releaseVersion} ===="
+ cd ./build/horizon || { echo 'ERROR: Build directory not found' ; exit 1; }
+ # 写入新版本号
+ npm version "${releaseVersion}"
+ cat >.npmrc <<- EndOfMessage
+registry=https://cmc.centralrepo.rnd.huawei.com/npm
+@cloudsop:registry=https://cmc.centralrepo.rnd.huawei.com/artifactory/api/npm/product_npm
+_auth = Y2xvdWRzb3BhcnRpZmFjdG9yeTpDbG91ZHNvcDY2NiEhIQ
+always-auth = true
+email = cloudsop@huawei.com
+EndOfMessage
+
+ echo "==== Publish new version===="
+ # npm仓库发布接口返回HTML,屏蔽错误码
+ npm publish || echo 'WARNING: Parsing publish response failed'
+ npm view @cloudsop/horizon@"${releaseVersion}"
+else
+ echo "No release version, quit."
+fi
+
diff --git a/.eslintrc.js b/.eslintrc.js
index 43a84822..860de8a4 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -1,3 +1,18 @@
+/*
+ * 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.
+ */
+
module.exports = {
extends: [
'eslint:recommended',
diff --git a/.idea/copyright/huawei.xml b/.idea/copyright/huawei.xml
new file mode 100644
index 00000000..ce060b15
--- /dev/null
+++ b/.idea/copyright/huawei.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
new file mode 100644
index 00000000..258fa527
--- /dev/null
+++ b/.idea/copyright/profiles_settings.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/.prettierrc.js b/.prettierrc.js
index 18746c04..9835a18f 100644
--- a/.prettierrc.js
+++ b/.prettierrc.js
@@ -1,3 +1,18 @@
+/*
+ * 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.
+ */
+
'use strict';
module.exports = {
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d8d338d8..b1b9cfbc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,15 @@
+## 0.0.26 (2022-11-09)
+- **CI**: 包信息同步CMC
+
+## 0.0.25 (2022-11-03)
+- **core**: fix 修改IE中Set的不兼容问题
+
+## 0.0.24 (2022-10-25)
+- **core**: fix 修改IE上报Symbol错误的问题
+
+## 0.0.23 (2022-09-23)
+- **core**: #86 兼容ReactIs API
+
## 0.0.22 (2022-09-22)
- **core**: #83 #75 #72 input支持受控
diff --git a/License b/License
new file mode 100644
index 00000000..0d8d3801
--- /dev/null
+++ b/License
@@ -0,0 +1,125 @@
+木兰宽松许可证, 第2版
+木兰宽松许可证, 第2版
+
+2020年1月 http://license.coscl.org.cn/MulanPSL2
+
+您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第2版(“本许可证”)的如下条款的约束:
+
+0. 定义
+
+“软件” 是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。
+
+“贡献” 是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。
+
+“贡献者” 是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。
+
+“法人实体” 是指提交贡献的机构及其“关联实体”。
+
+“关联实体” 是指,对“本许可证”下的行为方而言,控制、受控制或与其共同受控制的机构,此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。
+
+1. 授予版权许可
+
+每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。
+
+2. 授予专利许可
+
+每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。
+
+3. 无商标许可
+
+“本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定的声明义务而必须使用除外。
+
+4. 分发限制
+
+您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。
+
+5. 免责声明与责任限制
+
+“软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。
+
+6. 语言
+
+“本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。
+
+条款结束
+
+如何将木兰宽松许可证,第2版,应用到您的软件
+
+如果您希望将木兰宽松许可证,第2版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步:
+
+1, 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字;
+
+2, 请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中;
+
+3, 请将如下声明文本放入每个源文件的头部注释中。
+
+Copyright (c) [Year] [name of copyright holder]
+[Software Name] 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.
+Mulan Permissive Software License,Version 2
+Mulan Permissive Software License,Version 2 (Mulan PSL v2)
+
+January 2020 http://license.coscl.org.cn/MulanPSL2
+
+Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions:
+
+0. Definition
+
+Software means the program and related documents which are licensed under this License and comprise all Contribution(s).
+
+Contribution means the copyrightable work licensed by a particular Contributor under this License.
+
+Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License.
+
+Legal Entity means the entity making a Contribution and all its Affiliates.
+
+Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity.
+
+1. Grant of Copyright License
+
+Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not.
+
+2. Grant of Patent License
+
+Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken.
+
+3. No Trademark License
+
+No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in section 4.
+
+4. Distribution Restriction
+
+You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software.
+
+5. Disclaimer of Warranty and Limitation of Liability
+
+THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW IT’S CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+6. Language
+
+THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL.
+
+END OF THE TERMS AND CONDITIONS
+
+How to Apply the Mulan Permissive Software License,Version 2 (Mulan PSL v2) to Your Software
+
+To apply the Mulan PSL v2 to your work, for easy identification by recipients, you are suggested to complete following three steps:
+
+Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner;
+Create a file named "LICENSE" which contains the whole context of this License in the first directory of your software package;
+Attach the statement to the appropriate annotated syntax at the beginning of each source file.
+Copyright (c) [Year] [name of copyright holder]
+[Software Name] 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.
diff --git a/babel.config.js b/babel.config.js
index dd703552..46b2d085 100644
--- a/babel.config.js
+++ b/babel.config.js
@@ -1,3 +1,18 @@
+/*
+ * 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.
+ */
+
module.exports = {
presets: ['@babel/preset-typescript', ['@babel/preset-env', { targets: { node: 'current' } }]],
plugins: [
diff --git a/jest.config.js b/jest.config.js
index c0193a04..ddff3e15 100644
--- a/jest.config.js
+++ b/jest.config.js
@@ -1,3 +1,18 @@
+/*
+ * 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.
+ */
+
module.exports = {
coverageDirectory: 'coverage',
resetModules: true,
diff --git a/libs/horizon/global.d.ts b/libs/horizon/global.d.ts
index a3777f70..34c32508 100644
--- a/libs/horizon/global.d.ts
+++ b/libs/horizon/global.d.ts
@@ -1,3 +1,18 @@
+/*
+ * 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.
+ */
+
/*
区分是否开发者模式
*/
diff --git a/libs/horizon/index.ts b/libs/horizon/index.ts
index 4c067a3e..59045fbb 100644
--- a/libs/horizon/index.ts
+++ b/libs/horizon/index.ts
@@ -1,3 +1,18 @@
+/*
+ * 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 {
TYPE_FRAGMENT as Fragment,
TYPE_PROFILER as Profiler,
@@ -30,7 +45,17 @@ import {
import { asyncUpdates } from './src/renderer/TreeBuilder';
import { callRenderQueueImmediate } from './src/renderer/taskExecutor/RenderQueue';
import { runAsyncEffects } from './src/renderer/submit/HookEffectHandler';
-
+import {
+ isContextProvider,
+ isContextConsumer,
+ isElement,
+ isValidElementType,
+ isForwardRef,
+ isFragment,
+ isLazy,
+ isMemo,
+ isPortal,
+} from './src/external/HorizonIs';
import { createStore, useStore, clearStore } from './src/horizonx/store/StoreHandler';
import * as reduxAdapter from './src/horizonx/adapters/redux';
import { watch } from './src/horizonx/proxy/watch';
@@ -87,6 +112,15 @@ const Horizon = {
clearStore,
reduxAdapter,
watch,
+ isFragment,
+ isElement,
+ isValidElementType,
+ isForwardRef,
+ isLazy,
+ isMemo,
+ isPortal,
+ isContextProvider,
+ isContextConsumer,
};
export const version = __VERSION__;
@@ -128,6 +162,16 @@ export {
clearStore,
reduxAdapter,
watch,
+ // 兼容ReactIs
+ isFragment,
+ isElement,
+ isValidElementType,
+ isForwardRef,
+ isLazy,
+ isMemo,
+ isPortal,
+ isContextProvider,
+ isContextConsumer,
};
export default Horizon;
diff --git a/libs/horizon/npm/index.js b/libs/horizon/npm/index.js
index 5e307ea8..c2cf8335 100644
--- a/libs/horizon/npm/index.js
+++ b/libs/horizon/npm/index.js
@@ -1,3 +1,18 @@
+/*
+ * 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.
+ */
+
'use strict';
if (process.env.NODE_ENV === 'production') {
diff --git a/libs/horizon/package.json b/libs/horizon/package.json
index 0950fd50..0658232f 100644
--- a/libs/horizon/package.json
+++ b/libs/horizon/package.json
@@ -4,7 +4,7 @@
"keywords": [
"horizon"
],
- "version": "0.0.22",
+ "version": "0.0.26",
"homepage": "",
"bugs": "",
"main": "index.js",
diff --git a/libs/horizon/src/dom/DOMExternal.ts b/libs/horizon/src/dom/DOMExternal.ts
index 0baa43c2..556f5952 100644
--- a/libs/horizon/src/dom/DOMExternal.ts
+++ b/libs/horizon/src/dom/DOMExternal.ts
@@ -1,3 +1,18 @@
+/*
+ * 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, getFirstCustomDom, syncUpdates, startUpdate, createTreeRootVNode } from '../renderer/Renderer';
import { createPortal } from '../renderer/components/CreatePortal';
import type { Container } from './DOMOperator';
diff --git a/libs/horizon/src/dom/DOMInternalKeys.ts b/libs/horizon/src/dom/DOMInternalKeys.ts
index f389a0cf..f3ac8089 100644
--- a/libs/horizon/src/dom/DOMInternalKeys.ts
+++ b/libs/horizon/src/dom/DOMInternalKeys.ts
@@ -1,18 +1,26 @@
+/*
+ * 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.
+ */
+
/**
* 文件整体功能:给dom节点赋 VNode 的结构体和事件初始化标记
*/
-import type {VNode} from '../renderer/Types';
-import type {
- Container,
- Props,
-} from './DOMOperator';
+import type { VNode } from '../renderer/Types';
+import type { Container, Props } from './DOMOperator';
-import {
- DomComponent,
- DomText,
- TreeRoot,
-} from '../renderer/vnode/VNodeTags';
+import { DomComponent, DomText, TreeRoot } from '../renderer/vnode/VNodeTags';
const INTERNAL_VNODE = '_horizon_VNode';
const INTERNAL_PROPS = '_horizon_Props';
@@ -20,7 +28,7 @@ const INTERNAL_NONDELEGATEEVENTS = '_horizon_NonDelegatedEvents';
// 通过 VNode 实例获取 DOM 节点
export function getDom(vNode: VNode): Element | Text | null {
- const {tag} = vNode;
+ const { tag } = vNode;
if (tag === DomComponent || tag === DomText) {
return vNode.realNode;
}
@@ -28,18 +36,15 @@ export function getDom(vNode: VNode): Element | Text | null {
}
// 将 VNode 属性相关信息挂到 DOM 对象的特定属性上
-export function saveVNode(
- vNode: VNode,
- dom: Element | Text | Container,
-): void {
+export function saveVNode(vNode: VNode, dom: Element | Text | Container): void {
dom[INTERNAL_VNODE] = vNode;
}
// 用 DOM 节点,来找其对应的 VNode 实例
-export function getVNode(dom: Node|Container): VNode | null {
+export function getVNode(dom: Node | Container): VNode | null {
const vNode = dom[INTERNAL_VNODE] || (dom as Container)._treeRoot;
if (vNode) {
- const {tag} = vNode;
+ const { tag } = vNode;
if (tag === DomComponent || tag === DomText || tag === TreeRoot) {
return vNode;
}
@@ -63,7 +68,7 @@ export function getNearestVNode(dom: Node): null | VNode {
}
// 获取 vNode 上的属性相关信息
-export function getVNodeProps(dom: Element | Text): Props | null{
+export function getVNodeProps(dom: Element | Text): Props | null {
return dom[INTERNAL_PROPS] || null;
}
diff --git a/libs/horizon/src/dom/DOMOperator.ts b/libs/horizon/src/dom/DOMOperator.ts
index dfa668de..ed3047b8 100644
--- a/libs/horizon/src/dom/DOMOperator.ts
+++ b/libs/horizon/src/dom/DOMOperator.ts
@@ -1,24 +1,27 @@
-import {
- saveVNode,
- updateVNodeProps,
-} from './DOMInternalKeys';
-import {
- createDom,
-} from './utils/DomCreator';
+/*
+ * 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 { saveVNode, updateVNodeProps } from './DOMInternalKeys';
+import { createDom } from './utils/DomCreator';
import { getSelectionInfo, resetSelectionRange, SelectionData } from './SelectionRangeHandler';
import { shouldAutoFocus } from './utils/Common';
import { NSS } from './utils/DomCreator';
import { adjustStyleValue } from './DOMPropertiesHandler/StyleHandler';
import type { VNode } from '../renderer/Types';
-import {
- setInitValue,
- getPropsWithoutValue,
- updateValue,
-} from './valueHandler';
-import {
- compareProps,
- setDomProps,
-} from './DOMPropertiesHandler/DOMPropertiesHandler';
+import { setInitValue, getPropsWithoutValue, updateValue } from './valueHandler';
+import { compareProps, setDomProps } from './DOMPropertiesHandler/DOMPropertiesHandler';
import { isNativeElement, validateProps } from './validators/ValidateProps';
import { watchValueChange } from './valueHandler/ValueChangeHandler';
import { DomComponent, DomText } from '../renderer/vnode/VNodeTags';
@@ -66,12 +69,7 @@ export function resetAfterSubmit(): void {
}
// 创建 DOM 对象
-export function newDom(
- tagName: string,
- props: Props,
- parentNamespace: string,
- vNode: VNode,
-): Element {
+export function newDom(tagName: string, props: Props, parentNamespace: string, vNode: VNode): Element {
const dom: Element = createDom(tagName, parentNamespace);
// 将 vNode 节点挂到 DOM 对象上
saveVNode(vNode, dom);
@@ -104,12 +102,7 @@ export function initDomProps(dom: Element, tagName: string, rawProps: Props): bo
}
// 准备更新之前进行一系列校验 DOM,寻找属性差异等准备工作
-export function getPropChangeList(
- dom: Element,
- type: string,
- lastRawProps: Props,
- nextRawProps: Props,
-): Object {
+export function getPropChangeList(dom: Element, type: string, lastRawProps: Props, nextRawProps: Props): Object {
// 校验两个对象的不同
validateProps(type, nextRawProps);
@@ -136,10 +129,7 @@ export function isTextChild(type: string, props: Props): boolean {
}
}
-export function newTextDom(
- text: string,
- processing: VNode,
-): Text {
+export function newTextDom(text: string, processing: VNode): Text {
const textNode: Text = document.createTextNode(text);
saveVNode(processing, textNode);
return textNode;
@@ -183,26 +173,16 @@ export function clearText(dom: Element): void {
}
// 添加child元素
-export function appendChildElement(
- parent: Element | Container,
- child: Element | Text
-): void {
+export function appendChildElement(parent: Element | Container, child: Element | Text): void {
parent.appendChild(child);
}
// 插入dom元素
-export function insertDomBefore(
- parent: Element | Container,
- child: Element | Text,
- beforeChild: Element | Text,
-) {
+export function insertDomBefore(parent: Element | Container, child: Element | Text, beforeChild: Element | Text) {
parent.insertBefore(child, beforeChild);
}
-export function removeChildDom(
- parent: Element | Container,
- child: Element | Text
-) {
+export function removeChildDom(parent: Element | Container, child: Element | Text) {
parent.removeChild(child);
}
diff --git a/libs/horizon/src/dom/DOMPropertiesHandler/DOMPropertiesHandler.ts b/libs/horizon/src/dom/DOMPropertiesHandler/DOMPropertiesHandler.ts
index 0d9dc259..a0ab84b3 100644
--- a/libs/horizon/src/dom/DOMPropertiesHandler/DOMPropertiesHandler.ts
+++ b/libs/horizon/src/dom/DOMPropertiesHandler/DOMPropertiesHandler.ts
@@ -1,3 +1,18 @@
+/*
+ * 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 { allDelegatedHorizonEvents } from '../../event/EventHub';
import { updateCommonProp } from './UpdateCommonProp';
import { setStyles } from './StyleHandler';
@@ -66,11 +81,7 @@ export function compareProps(oldProps: Object, newProps: Object): Object {
styleProp = styleProps[j];
updatesForStyle[styleProp] = '';
}
- } else if (
- propName === 'autoFocus' ||
- propName === 'children' ||
- propName === 'dangerouslySetInnerHTML'
- ) {
+ } else if (propName === 'autoFocus' || propName === 'children' || propName === 'dangerouslySetInnerHTML') {
continue;
} else if (isEventProp(propName)) {
if (!allDelegatedHorizonEvents.has(propName)) {
diff --git a/libs/horizon/src/dom/DOMPropertiesHandler/StyleHandler.ts b/libs/horizon/src/dom/DOMPropertiesHandler/StyleHandler.ts
index b93e1581..012f438f 100644
--- a/libs/horizon/src/dom/DOMPropertiesHandler/StyleHandler.ts
+++ b/libs/horizon/src/dom/DOMPropertiesHandler/StyleHandler.ts
@@ -1,12 +1,29 @@
+/*
+ * 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.
+ */
+
function isNeedUnitCSS(styleName: string) {
- return !(noUnitCSS.includes(styleName)
- || styleName.startsWith('borderImage')
- || styleName.startsWith('flex')
- || styleName.startsWith('gridRow')
- || styleName.startsWith('gridColumn')
- || styleName.startsWith('stroke')
- || styleName.startsWith('box')
- || styleName.endsWith('Opacity'));
+ return !(
+ noUnitCSS.includes(styleName) ||
+ styleName.startsWith('borderImage') ||
+ styleName.startsWith('flex') ||
+ styleName.startsWith('gridRow') ||
+ styleName.startsWith('gridColumn') ||
+ styleName.startsWith('stroke') ||
+ styleName.startsWith('box') ||
+ styleName.endsWith('Opacity')
+ );
}
/**
@@ -14,7 +31,7 @@ function isNeedUnitCSS(styleName: string) {
* 对空值或布尔值进行适配,转为空字符串
* 去掉多余空字符
*/
- export function adjustStyleValue(name, value) {
+export function adjustStyleValue(name, value) {
let validValue = value;
if (typeof value === 'number' && value !== 0 && isNeedUnitCSS(name)) {
@@ -35,7 +52,7 @@ export function setStyles(dom, styles) {
}
const style = dom.style;
- Object.keys(styles).forEach((name) => {
+ Object.keys(styles).forEach(name => {
const styleVal = styles[name];
style[name] = adjustStyleValue(name, styleVal);
@@ -45,5 +62,19 @@ export function setStyles(dom, styles) {
/**
* 不需要加长度单位的 css 属性
*/
-const noUnitCSS = ['animationIterationCount', 'columnCount', 'columns', 'gridArea', 'fontWeight', 'lineClamp',
- 'lineHeight', 'opacity', 'order', 'orphans', 'tabSize', 'widows', 'zIndex', 'zoom'];
+const noUnitCSS = [
+ 'animationIterationCount',
+ 'columnCount',
+ 'columns',
+ 'gridArea',
+ 'fontWeight',
+ 'lineClamp',
+ 'lineHeight',
+ 'opacity',
+ 'order',
+ 'orphans',
+ 'tabSize',
+ 'widows',
+ 'zIndex',
+ 'zoom',
+];
diff --git a/libs/horizon/src/dom/DOMPropertiesHandler/UpdateCommonProp.ts b/libs/horizon/src/dom/DOMPropertiesHandler/UpdateCommonProp.ts
index 468408ac..2fc56869 100644
--- a/libs/horizon/src/dom/DOMPropertiesHandler/UpdateCommonProp.ts
+++ b/libs/horizon/src/dom/DOMPropertiesHandler/UpdateCommonProp.ts
@@ -1,22 +1,91 @@
-import {
- getPropDetails,
- PROPERTY_TYPE,
-} from '../validators/PropertiesData';
-import {isInvalidValue} from '../validators/ValidateProps';
-import {getNamespaceCtx} from '../../renderer/ContextSaver';
-import {NSS} from '../utils/DomCreator';
-import {getDomTag} from '../utils/Common';
+/*
+ * 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.
+ */
-const svgHumpAttr = new Set(['allowReorder', 'autoReverse', 'baseFrequency', 'baseProfile', 'calcMode', 'clipPathUnits',
- 'contentScriptType', 'contentStyleType', 'diffuseConstant', 'edgeMode', 'externalResourcesRequired', 'filterRes',
- 'filterUnits', 'glyphRef', 'gradientTransform', 'gradientUnits', 'kernelMatrix', 'kernelUnitLength', 'keyPoints',
- 'keySplines', 'keyTimes', 'lengthAdjust', 'limitingConeAngle', 'markerHeight', 'markerUnits', 'markerWidth',
- 'maskContentUnits', 'maskUnits', 'numOctaves', 'pathLength', 'patternContentUnits', 'patternTransform,',
- 'patternUnits', 'pointsAtX', 'pointsAtY', 'pointsAtZ', 'preserveAlpha', 'preserveAspectRatio', 'primitiveUnits',
- 'referrerPolicy', 'refX', 'refY', 'repeatCount', 'repeatDur', 'requiredExtensions', 'requiredFeatures',
- 'specularConstant', 'specularExponent', 'spreadMethod', 'startOffset', 'stdDeviation',
- 'stitchTiles', 'surfaceScale','systemLanguage', 'tableValues', 'targetX', 'targetY',
- 'textLength','viewBox', 'viewTarget', 'xChannelSelector','yChannelSelector', 'zoomAndPan']);
+import { getPropDetails, PROPERTY_TYPE } from '../validators/PropertiesData';
+import { isInvalidValue } from '../validators/ValidateProps';
+import { getNamespaceCtx } from '../../renderer/ContextSaver';
+import { NSS } from '../utils/DomCreator';
+import { getDomTag } from '../utils/Common';
+
+// 不需要装换的svg属性集合
+const svgHumpAttr = new Set();
+[
+ 'allowReorder',
+ 'autoReverse',
+ 'baseFrequency',
+ 'baseProfile',
+ 'calcMode',
+ 'clipPathUnits',
+ 'contentScriptType',
+ 'contentStyleType',
+ 'diffuseConstant',
+ 'edgeMode',
+ 'externalResourcesRequired',
+ 'filterRes',
+ 'filterUnits',
+ 'glyphRef',
+ 'gradientTransform',
+ 'gradientUnits',
+ 'kernelMatrix',
+ 'kernelUnitLength',
+ 'keyPoints',
+ 'keySplines',
+ 'keyTimes',
+ 'lengthAdjust',
+ 'limitingConeAngle',
+ 'markerHeight',
+ 'markerUnits',
+ 'markerWidth',
+ 'maskContentUnits',
+ 'maskUnits',
+ 'numOctaves',
+ 'pathLength',
+ 'patternContentUnits',
+ 'patternTransform,',
+ 'patternUnits',
+ 'pointsAtX',
+ 'pointsAtY',
+ 'pointsAtZ',
+ 'preserveAlpha',
+ 'preserveAspectRatio',
+ 'primitiveUnits',
+ 'referrerPolicy',
+ 'refX',
+ 'refY',
+ 'repeatCount',
+ 'repeatDur',
+ 'requiredExtensions',
+ 'requiredFeatures',
+ 'specularConstant',
+ 'specularExponent',
+ 'spreadMethod',
+ 'startOffset',
+ 'stdDeviation',
+ 'stitchTiles',
+ 'surfaceScale',
+ 'systemLanguage',
+ 'tableValues',
+ 'targetX',
+ 'targetY',
+ 'textLength',
+ 'viewBox',
+ 'viewTarget',
+ 'xChannelSelector',
+ 'yChannelSelector',
+ 'zoomAndPan',
+].forEach((name) => svgHumpAttr.add(name));
// 驼峰 变 “-”
function convertToLowerCase(str) {
@@ -50,19 +119,22 @@ export function updateCommonProp(dom: Element, attrName: string, value: any, isN
dom.setAttribute(attrName, String(value));
}
} else if (['checked', 'multiple', 'muted', 'selected'].includes(propDetails.attrName)) {
- if (value === null) { // 必填属性设置默认值
+ if (value === null) {
+ // 必填属性设置默认值
dom[propDetails.attrName] = false;
} else {
dom[propDetails.attrName] = value;
}
- } else { // 处理其他普通属性
+ } else {
+ // 处理其他普通属性
if (value === null) {
dom.removeAttribute(propDetails.attrName);
} else {
- const {type, attrNS} = propDetails; // 数据类型、固有属性命名空间
+ const { type, attrNS } = propDetails; // 数据类型、固有属性命名空间
const attributeName = propDetails.attrName; // 固有属性名
let attributeValue;
- if (type === PROPERTY_TYPE.BOOLEAN) { // 即可以用作标志又可以是属性值的属性
+ if (type === PROPERTY_TYPE.BOOLEAN) {
+ // 即可以用作标志又可以是属性值的属性
attributeValue = '';
} else {
attributeValue = String(value);
diff --git a/libs/horizon/src/dom/SelectionRangeHandler.ts b/libs/horizon/src/dom/SelectionRangeHandler.ts
index 284faa41..e09e0dad 100644
--- a/libs/horizon/src/dom/SelectionRangeHandler.ts
+++ b/libs/horizon/src/dom/SelectionRangeHandler.ts
@@ -1,10 +1,25 @@
+/*
+ * 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 {getIFrameFocusedDom, isText} from './utils/Common';
+import { getIFrameFocusedDom, isText } from './utils/Common';
-import {isElement} from './utils/Common';
+import { isElement } from './utils/Common';
/**
* 设置聚焦的 textarea 或 input 节点的选择范围
@@ -61,7 +76,8 @@ function isNodeContainsByTargetNode(targetNode, node) {
if (typeof targetNode.contains === 'function') {
return targetNode.contains(node); // 该的节点是否为目标节点的后代节点
}
- if (typeof targetNode.compareDocumentPosition === 'function') { // compareDocumentPosition 数值,表示两个节点彼此做比较的位置
+ if (typeof targetNode.compareDocumentPosition === 'function') {
+ // compareDocumentPosition 数值,表示两个节点彼此做比较的位置
const CONTAINS_CODE = 16;
// 返回 16 代表 第二节点在第一节点内部
return targetNode.compareDocumentPosition(node) === CONTAINS_CODE;
@@ -138,9 +154,10 @@ export function resetSelectionRange(preSelectionRangeData: SelectionData) {
let ancestor = preFocusedDom.parentNode;
// 查找先前的 focus 节点的先祖
while (ancestor) {
- if (isElement(ancestor)) { // 是元素节点,就把先祖信息放到先祖数组中
+ if (isElement(ancestor)) {
+ // 是元素节点,就把先祖信息放到先祖数组中
// @ts-ignore
- const {scrollLeft, scrollTop} = ancestor;
+ const { scrollLeft, scrollTop } = ancestor;
ancestors.push({
dom: ancestor,
scrollLeft,
diff --git a/libs/horizon/src/dom/utils/Common.ts b/libs/horizon/src/dom/utils/Common.ts
index 3ed6a462..30c172cf 100644
--- a/libs/horizon/src/dom/utils/Common.ts
+++ b/libs/horizon/src/dom/utils/Common.ts
@@ -1,5 +1,20 @@
-import {HorizonDom} from './Interface';
-import {Props} from '../DOMOperator';
+/*
+ * 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 { HorizonDom } from './Interface';
+import { Props } from '../DOMOperator';
/**
* 获取当前聚焦的 input 或者 textarea 元素
@@ -20,12 +35,15 @@ export function getIFrameFocusedDom() {
while (focusedDom instanceof currentWindow.HTMLIFrameElement) {
try {
// 访问 HTMLIframeElement 的 contentDocument 可能会导致浏览器抛出错误
- if (typeof focusedDom.contentWindow.location.href === 'string') { // iframe 的内容为同源
+ if (typeof focusedDom.contentWindow.location.href === 'string') {
+ // iframe 的内容为同源
focusedDom = getFocusedDom(focusedDom.contentWindow.document);
- } else { // 非同源 iframe 因为安全性原因无法获取其中的具体元素
+ } else {
+ // 非同源 iframe 因为安全性原因无法获取其中的具体元素
break;
}
- } catch (e) { // 非同源 iframe 因为安全性原因无法获取其中的具体元素
+ } catch (e) {
+ // 非同源 iframe 因为安全性原因无法获取其中的具体元素
break;
}
}
diff --git a/libs/horizon/src/dom/utils/DomCreator.ts b/libs/horizon/src/dom/utils/DomCreator.ts
index 360aea81..3eb2d1ca 100644
--- a/libs/horizon/src/dom/utils/DomCreator.ts
+++ b/libs/horizon/src/dom/utils/DomCreator.ts
@@ -1,3 +1,17 @@
+/*
+ * 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.
+ */
export const NSS = {
html: 'http://www.w3.org/1999/xhtml',
@@ -6,10 +20,7 @@ export const NSS = {
};
// 创建DOM元素
-export function createDom(
- tagName: string,
- parentNamespace: string,
-): Element {
+export function createDom(tagName: string, parentNamespace: string): Element {
let dom: Element;
const selfNamespace = NSS[tagName] || NSS.html;
const ns = parentNamespace !== NSS.html ? parentNamespace : selfNamespace;
diff --git a/libs/horizon/src/dom/utils/Interface.ts b/libs/horizon/src/dom/utils/Interface.ts
index b6a901e3..dd8e2c52 100644
--- a/libs/horizon/src/dom/utils/Interface.ts
+++ b/libs/horizon/src/dom/utils/Interface.ts
@@ -1,3 +1,18 @@
+/*
+ * 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.
+ */
+
export interface Props {
[propName: string]: any;
}
diff --git a/libs/horizon/src/dom/validators/PropertiesData.ts b/libs/horizon/src/dom/validators/PropertiesData.ts
index 70645aae..f2db0dd8 100644
--- a/libs/horizon/src/dom/validators/PropertiesData.ts
+++ b/libs/horizon/src/dom/validators/PropertiesData.ts
@@ -1,3 +1,18 @@
+/*
+ * 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.
+ */
+
/* eslint-disable no-sparse-arrays */
// 属性值的数据类型
diff --git a/libs/horizon/src/dom/validators/ValidateProps.ts b/libs/horizon/src/dom/validators/ValidateProps.ts
index 9dcf4a23..d6629b29 100644
--- a/libs/horizon/src/dom/validators/ValidateProps.ts
+++ b/libs/horizon/src/dom/validators/ValidateProps.ts
@@ -1,20 +1,28 @@
-import {
- getPropDetails, PROPERTY_TYPE, PropDetails,
-} from './PropertiesData';
+/*
+ * 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 { getPropDetails, PROPERTY_TYPE, PropDetails } from './PropertiesData';
const INVALID_EVENT_NAME_REGEX = /^on[^A-Z]/;
-
// 是内置元素
export function isNativeElement(tagName: string, props: Record) {
return !tagName.includes('-') && props.is === undefined;
}
-function isInvalidBoolean(
- attributeName: string,
- value: any,
- propDetails: PropDetails,
-): boolean {
+function isInvalidBoolean(attributeName: string, value: any, propDetails: PropDetails): boolean {
if (propDetails.type === PROPERTY_TYPE.SPECIAL) {
return false;
}
@@ -63,7 +71,7 @@ export function isInvalidValue(
name: string,
value: any,
propDetails: PropDetails | null,
- isNativeTag: boolean,
+ isNativeTag: boolean
): boolean {
if (value == null) {
return true;
@@ -107,11 +115,7 @@ export function validateProps(type, props) {
const propString = invalidProps.map(prop => '`' + prop + '`').join(', ');
if (invalidProps.length >= 1) {
- console.error(
- 'Invalid value for prop %s on <%s> tag.',
- propString,
- type,
- );
+ console.error('Invalid value for prop %s on <%s> tag.', propString, type);
}
}
}
diff --git a/libs/horizon/src/dom/valueHandler/InputValueHandler.ts b/libs/horizon/src/dom/valueHandler/InputValueHandler.ts
index d9e9f8ef..824d57dd 100644
--- a/libs/horizon/src/dom/valueHandler/InputValueHandler.ts
+++ b/libs/horizon/src/dom/valueHandler/InputValueHandler.ts
@@ -1,3 +1,18 @@
+/*
+ * 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 { updateCommonProp } from '../DOMPropertiesHandler/UpdateCommonProp';
import { Props } from '../utils/Interface';
@@ -13,7 +28,7 @@ function getInitValue(dom: HTMLInputElement, props: Props) {
export function getInputPropsWithoutValue(dom: HTMLInputElement, props: Props) {
// checked属于必填属性,无法置
- let {checked} = props;
+ let { checked } = props;
if (checked == null) {
checked = getInitValue(dom, props).initChecked;
}
@@ -28,9 +43,10 @@ export function getInputPropsWithoutValue(dom: HTMLInputElement, props: Props) {
}
export function updateInputValue(dom: HTMLInputElement, props: Props) {
- const {value, checked} = props;
+ const { value, checked } = props;
- if (value != null) { // 处理 dom.value 逻辑
+ if (value != null) {
+ // 处理 dom.value 逻辑
if (dom.value !== String(value)) {
dom.value = String(value);
}
@@ -41,8 +57,8 @@ export function updateInputValue(dom: HTMLInputElement, props: Props) {
// 设置input的初始值
export function setInitInputValue(dom: HTMLInputElement, props: Props) {
- const {value, defaultValue} = props;
- const {initValue, initChecked} = getInitValue(dom, props);
+ const { value, defaultValue } = props;
+ const { initValue, initChecked } = getInitValue(dom, props);
if (value != null || defaultValue != null) {
// value 的使用优先级 value 属性 > defaultValue 属性 > 空字符串
diff --git a/libs/horizon/src/dom/valueHandler/OptionValueHandler.ts b/libs/horizon/src/dom/valueHandler/OptionValueHandler.ts
index 3f867293..d1c8022a 100644
--- a/libs/horizon/src/dom/valueHandler/OptionValueHandler.ts
+++ b/libs/horizon/src/dom/valueHandler/OptionValueHandler.ts
@@ -1,10 +1,25 @@
+/*
+ * 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 { Children } from '../../external/ChildrenUtil';
import { Props } from '../utils/Interface';
// 把 const a = 'a'; 转成 giraffe
function concatChildren(children) {
let content = '';
- Children.forEach(children, function(child) {
+ Children.forEach(children, function (child) {
content += child;
});
diff --git a/libs/horizon/src/dom/valueHandler/SelectValueHandler.ts b/libs/horizon/src/dom/valueHandler/SelectValueHandler.ts
index c651432b..fb9f859e 100644
--- a/libs/horizon/src/dom/valueHandler/SelectValueHandler.ts
+++ b/libs/horizon/src/dom/valueHandler/SelectValueHandler.ts
@@ -1,9 +1,24 @@
-import {HorizonSelect, Props} from '../utils/Interface';
+/*
+ * 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 { HorizonSelect, Props } from '../utils/Interface';
function updateMultipleValue(options, newValues) {
const newValueSet = new Set();
- newValues.forEach((val) => {
+ newValues.forEach(val => {
newValueSet.add(String(val));
});
@@ -46,8 +61,8 @@ export function getSelectPropsWithoutValue(dom: HorizonSelect, properties: Objec
};
}
-export function updateSelectValue(dom: HorizonSelect, props: Props, isInit: boolean = false) {
- const {value, defaultValue, multiple} = props;
+export function updateSelectValue(dom: HorizonSelect, props: Props, isInit = false) {
+ const { value, defaultValue, multiple } = props;
const oldMultiple = dom._multiple !== undefined ? dom._multiple : dom.multiple;
const newMultiple = Boolean(multiple);
@@ -56,7 +71,8 @@ export function updateSelectValue(dom: HorizonSelect, props: Props, isInit: bool
// 设置了 value 属性
if (value != null) {
updateValue(dom.options, value, newMultiple);
- } else if (oldMultiple !== newMultiple) { // 修改了 multiple 属性
+ } else if (oldMultiple !== newMultiple) {
+ // 修改了 multiple 属性
// 切换 multiple 之后,如果设置了 defaultValue 需要重新应用
if (defaultValue != null) {
updateValue(dom.options, defaultValue, newMultiple);
@@ -64,7 +80,8 @@ export function updateSelectValue(dom: HorizonSelect, props: Props, isInit: bool
// 恢复到未选定状态
updateValue(dom.options, newMultiple ? [] : '', newMultiple);
}
- } else if (isInit && defaultValue != null) { // 设置了 defaultValue 属性
+ } else if (isInit && defaultValue != null) {
+ // 设置了 defaultValue 属性
updateValue(dom.options, defaultValue, newMultiple);
}
}
diff --git a/libs/horizon/src/dom/valueHandler/TextareaValueHandler.ts b/libs/horizon/src/dom/valueHandler/TextareaValueHandler.ts
index dd87c6ae..82b2203e 100644
--- a/libs/horizon/src/dom/valueHandler/TextareaValueHandler.ts
+++ b/libs/horizon/src/dom/valueHandler/TextareaValueHandler.ts
@@ -1,12 +1,26 @@
-import {Props} from '../utils/Interface';
+/*
+ * 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 { Props } from '../utils/Interface';
// 值的优先级 value > children > defaultValue
function getInitValue(props: Props) {
- const {value} = props;
+ const { value } = props;
if (value == null) {
- const {defaultValue, children} = props;
+ const { defaultValue, children } = props;
let initValue = defaultValue;
// children content存在时,会覆盖defaultValue
@@ -30,7 +44,7 @@ export function getTextareaPropsWithoutValue(dom: HTMLTextAreaElement, propertie
};
}
-export function updateTextareaValue(dom: HTMLTextAreaElement, props: Props, isInit: boolean = false) {
+export function updateTextareaValue(dom: HTMLTextAreaElement, props: Props, isInit = false) {
if (isInit) {
const initValue = getInitValue(props);
if (initValue !== '') {
@@ -48,4 +62,3 @@ export function updateTextareaValue(dom: HTMLTextAreaElement, props: Props, isIn
}
}
}
-
diff --git a/libs/horizon/src/dom/valueHandler/ValueChangeHandler.ts b/libs/horizon/src/dom/valueHandler/ValueChangeHandler.ts
index 134e980e..d1c39fd8 100644
--- a/libs/horizon/src/dom/valueHandler/ValueChangeHandler.ts
+++ b/libs/horizon/src/dom/valueHandler/ValueChangeHandler.ts
@@ -1,3 +1,18 @@
+/*
+ * 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.
+ */
+
/**
* Horizon的输入框和文本框的change事件在原生的change事件上做了一层处理
* 只有值发生变化时才会触发change事件。
@@ -37,7 +52,7 @@ export function watchValueChange(dom) {
const setFunc = descriptor?.set;
Object.defineProperty(dom, keyForValue, {
...descriptor,
- set: function(value) {
+ set: function (value) {
currentVal = String(value);
setFunc?.apply(this, [value]);
},
diff --git a/libs/horizon/src/dom/valueHandler/index.ts b/libs/horizon/src/dom/valueHandler/index.ts
index 178727d5..6e96281a 100644
--- a/libs/horizon/src/dom/valueHandler/index.ts
+++ b/libs/horizon/src/dom/valueHandler/index.ts
@@ -1,25 +1,28 @@
+/*
+ * 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.
+ */
+
/**
*