@whitesev/domutils 1.7.4 → 1.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.amd.js +31 -25
- package/dist/index.amd.js.map +1 -1
- package/dist/index.amd.min.js +1 -1
- package/dist/index.amd.min.js.map +1 -1
- package/dist/index.cjs.js +31 -25
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.cjs.min.js.map +1 -1
- package/dist/index.esm.js +31 -25
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.iife.js +31 -25
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.system.js +31 -25
- package/dist/index.system.js.map +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/index.system.min.js.map +1 -1
- package/dist/index.umd.js +31 -25
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/eslint.config.d.mts +2 -0
- package/package.json +8 -8
- package/src/Utils.ts +28 -26
package/dist/index.amd.js
CHANGED
|
@@ -523,7 +523,7 @@ define((function () { 'use strict';
|
|
|
523
523
|
},
|
|
524
524
|
};
|
|
525
525
|
|
|
526
|
-
const version = "1.7.
|
|
526
|
+
const version = "1.7.5";
|
|
527
527
|
|
|
528
528
|
/* 数据 */
|
|
529
529
|
const GlobalData = {
|
|
@@ -901,35 +901,41 @@ define((function () { 'use strict';
|
|
|
901
901
|
if (target == null) {
|
|
902
902
|
target = {};
|
|
903
903
|
}
|
|
904
|
+
// 当前遍历的目标对象
|
|
905
|
+
let iteratorTarget;
|
|
904
906
|
if (isAdd) {
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
const targetValue = Reflect.get(target, targetKeyName);
|
|
908
|
-
const sourceValue = Reflect.get(source, sourceKeyName);
|
|
909
|
-
if (typeof sourceValue === "object" && sourceValue != null && sourceKeyName in target && !isDOM(sourceValue)) {
|
|
910
|
-
/* 源端的值是object类型,且不是元素节点 */
|
|
911
|
-
Reflect.set(target, sourceKeyName, UtilsContext.assign(targetValue, sourceValue, isAdd));
|
|
912
|
-
continue;
|
|
913
|
-
}
|
|
914
|
-
Reflect.set(target, sourceKeyName, sourceValue);
|
|
915
|
-
}
|
|
907
|
+
// 追加并覆盖是以source为准
|
|
908
|
+
iteratorTarget = source;
|
|
916
909
|
}
|
|
917
910
|
else {
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
911
|
+
// 覆盖以target为准
|
|
912
|
+
iteratorTarget = target;
|
|
913
|
+
}
|
|
914
|
+
for (const keyName in iteratorTarget) {
|
|
915
|
+
if (!isAdd && !(keyName in source)) {
|
|
916
|
+
// 仅替换 但是源端没有此键
|
|
917
|
+
continue;
|
|
918
|
+
}
|
|
919
|
+
const targetValue = Reflect.get(target, keyName);
|
|
920
|
+
const sourceValue = Reflect.get(source, keyName);
|
|
921
|
+
if (typeof sourceValue === "object" && sourceValue != null && keyName in target && !isDOM(sourceValue)) {
|
|
922
|
+
// 源端的值是object类型,且不是元素节点
|
|
923
|
+
// 如果是数组,那此数组中有值,清空旧的数组再赋值
|
|
924
|
+
let childObjectValue;
|
|
925
|
+
if (Array.isArray(sourceValue)) {
|
|
926
|
+
if (Array.isArray(targetValue)) {
|
|
927
|
+
targetValue.length = 0;
|
|
929
928
|
}
|
|
930
|
-
|
|
931
|
-
|
|
929
|
+
childObjectValue = sourceValue;
|
|
930
|
+
}
|
|
931
|
+
else {
|
|
932
|
+
childObjectValue = UtilsContext.assign(targetValue, sourceValue, isAdd);
|
|
932
933
|
}
|
|
934
|
+
Reflect.set(target, keyName, childObjectValue);
|
|
935
|
+
}
|
|
936
|
+
else {
|
|
937
|
+
/* 直接赋值 */
|
|
938
|
+
Reflect.set(target, keyName, sourceValue);
|
|
933
939
|
}
|
|
934
940
|
}
|
|
935
941
|
return target;
|