@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.umd.js
CHANGED
|
@@ -316,38 +316,44 @@
|
|
|
316
316
|
if (target == null) {
|
|
317
317
|
target = {};
|
|
318
318
|
}
|
|
319
|
+
// 当前遍历的目标对象
|
|
320
|
+
let iteratorTarget;
|
|
319
321
|
if (isAdd) {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
const targetValue = Reflect.get(target, targetKeyName);
|
|
323
|
-
const sourceValue = Reflect.get(source, sourceKeyName);
|
|
324
|
-
if (typeof sourceValue === "object" &&
|
|
325
|
-
sourceValue != null &&
|
|
326
|
-
sourceKeyName in target &&
|
|
327
|
-
!UtilsContext.isDOM(sourceValue)) {
|
|
328
|
-
/* 源端的值是object类型,且不是元素节点 */
|
|
329
|
-
Reflect.set(target, sourceKeyName, UtilsContext.assign(targetValue, sourceValue, isAdd));
|
|
330
|
-
continue;
|
|
331
|
-
}
|
|
332
|
-
Reflect.set(target, sourceKeyName, sourceValue);
|
|
333
|
-
}
|
|
322
|
+
// 追加并覆盖是以source为准
|
|
323
|
+
iteratorTarget = source;
|
|
334
324
|
}
|
|
335
325
|
else {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
326
|
+
// 覆盖以target为准
|
|
327
|
+
iteratorTarget = target;
|
|
328
|
+
}
|
|
329
|
+
for (const keyName in iteratorTarget) {
|
|
330
|
+
if (!isAdd && !(keyName in source)) {
|
|
331
|
+
// 仅替换 但是源端没有此键
|
|
332
|
+
continue;
|
|
333
|
+
}
|
|
334
|
+
const targetValue = Reflect.get(target, keyName);
|
|
335
|
+
const sourceValue = Reflect.get(source, keyName);
|
|
336
|
+
if (typeof sourceValue === "object" &&
|
|
337
|
+
sourceValue != null &&
|
|
338
|
+
keyName in target &&
|
|
339
|
+
!UtilsContext.isDOM(sourceValue)) {
|
|
340
|
+
// 源端的值是object类型,且不是元素节点
|
|
341
|
+
// 如果是数组,那此数组中有值,清空旧的数组再赋值
|
|
342
|
+
let childObjectValue;
|
|
343
|
+
if (Array.isArray(sourceValue)) {
|
|
344
|
+
if (Array.isArray(targetValue)) {
|
|
345
|
+
targetValue.length = 0;
|
|
347
346
|
}
|
|
348
|
-
|
|
349
|
-
|
|
347
|
+
childObjectValue = sourceValue;
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
childObjectValue = UtilsContext.assign(targetValue, sourceValue, isAdd);
|
|
350
351
|
}
|
|
352
|
+
Reflect.set(target, keyName, childObjectValue);
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
/* 直接赋值 */
|
|
356
|
+
Reflect.set(target, keyName, sourceValue);
|
|
351
357
|
}
|
|
352
358
|
}
|
|
353
359
|
return target;
|
|
@@ -5496,7 +5502,7 @@
|
|
|
5496
5502
|
}
|
|
5497
5503
|
const domUtils = new DOMUtils();
|
|
5498
5504
|
|
|
5499
|
-
const version = "2.9.
|
|
5505
|
+
const version = "2.9.7";
|
|
5500
5506
|
|
|
5501
5507
|
class Utils {
|
|
5502
5508
|
windowApi;
|