@whitesev/utils 2.9.6 → 2.9.7
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 +34 -28
- 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 +34 -28
- 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 +34 -28
- 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 +34 -28
- 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 +34 -28
- 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 +34 -28
- 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/package.json +1 -1
- package/src/CommonUtil.ts +33 -31
package/dist/index.esm.js
CHANGED
|
@@ -310,38 +310,44 @@ class CommonUtil {
|
|
|
310
310
|
if (target == null) {
|
|
311
311
|
target = {};
|
|
312
312
|
}
|
|
313
|
+
// 当前遍历的目标对象
|
|
314
|
+
let iteratorTarget;
|
|
313
315
|
if (isAdd) {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
const targetValue = Reflect.get(target, targetKeyName);
|
|
317
|
-
const sourceValue = Reflect.get(source, sourceKeyName);
|
|
318
|
-
if (typeof sourceValue === "object" &&
|
|
319
|
-
sourceValue != null &&
|
|
320
|
-
sourceKeyName in target &&
|
|
321
|
-
!UtilsContext.isDOM(sourceValue)) {
|
|
322
|
-
/* 源端的值是object类型,且不是元素节点 */
|
|
323
|
-
Reflect.set(target, sourceKeyName, UtilsContext.assign(targetValue, sourceValue, isAdd));
|
|
324
|
-
continue;
|
|
325
|
-
}
|
|
326
|
-
Reflect.set(target, sourceKeyName, sourceValue);
|
|
327
|
-
}
|
|
316
|
+
// 追加并覆盖是以source为准
|
|
317
|
+
iteratorTarget = source;
|
|
328
318
|
}
|
|
329
319
|
else {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
320
|
+
// 覆盖以target为准
|
|
321
|
+
iteratorTarget = target;
|
|
322
|
+
}
|
|
323
|
+
for (const keyName in iteratorTarget) {
|
|
324
|
+
if (!isAdd && !(keyName in source)) {
|
|
325
|
+
// 仅替换 但是源端没有此键
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
const targetValue = Reflect.get(target, keyName);
|
|
329
|
+
const sourceValue = Reflect.get(source, keyName);
|
|
330
|
+
if (typeof sourceValue === "object" &&
|
|
331
|
+
sourceValue != null &&
|
|
332
|
+
keyName in target &&
|
|
333
|
+
!UtilsContext.isDOM(sourceValue)) {
|
|
334
|
+
// 源端的值是object类型,且不是元素节点
|
|
335
|
+
// 如果是数组,那此数组中有值,清空旧的数组再赋值
|
|
336
|
+
let childObjectValue;
|
|
337
|
+
if (Array.isArray(sourceValue)) {
|
|
338
|
+
if (Array.isArray(targetValue)) {
|
|
339
|
+
targetValue.length = 0;
|
|
341
340
|
}
|
|
342
|
-
|
|
343
|
-
|
|
341
|
+
childObjectValue = sourceValue;
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
childObjectValue = UtilsContext.assign(targetValue, sourceValue, isAdd);
|
|
344
345
|
}
|
|
346
|
+
Reflect.set(target, keyName, childObjectValue);
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
/* 直接赋值 */
|
|
350
|
+
Reflect.set(target, keyName, sourceValue);
|
|
345
351
|
}
|
|
346
352
|
}
|
|
347
353
|
return target;
|
|
@@ -5490,7 +5496,7 @@ class DOMUtils {
|
|
|
5490
5496
|
}
|
|
5491
5497
|
const domUtils = new DOMUtils();
|
|
5492
5498
|
|
|
5493
|
-
const version = "2.9.
|
|
5499
|
+
const version = "2.9.7";
|
|
5494
5500
|
|
|
5495
5501
|
class Utils {
|
|
5496
5502
|
windowApi;
|