@whitesev/domutils 1.7.3 → 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 +33 -27
- 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 +33 -27
- 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 +33 -27
- 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 +33 -27
- 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 +33 -27
- 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 +33 -27
- 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/dist/types/src/ElementEvent.d.ts +2 -2
- package/dist/types/src/index.d.ts +2 -2
- package/package.json +10 -10
- package/src/ElementEvent.ts +2 -2
- package/src/Utils.ts +28 -26
- package/src/index.ts +2 -2
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;
|
|
@@ -3284,12 +3290,12 @@ define((function () { 'use strict';
|
|
|
3284
3290
|
}
|
|
3285
3291
|
/**
|
|
3286
3292
|
* 移除元素
|
|
3287
|
-
* @param $el
|
|
3293
|
+
* @param $el 目标元素,可以是数组、单个元素、NodeList、元素选择器
|
|
3288
3294
|
* @example
|
|
3289
|
-
* // 元素a.xx前面添加一个元素
|
|
3290
3295
|
* DOMUtils.remove(document.querySelector("a.xx"))
|
|
3291
3296
|
* DOMUtils.remove(document.querySelectorAll("a.xx"))
|
|
3292
3297
|
* DOMUtils.remove("a.xx")
|
|
3298
|
+
* DOMUtils.remove([a.xxx, div.xxx, span.xxx])
|
|
3293
3299
|
* */
|
|
3294
3300
|
remove($el) {
|
|
3295
3301
|
const that = this;
|