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