@whitesev/utils 2.9.6 → 2.9.8
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 +38 -29
- 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 +38 -29
- 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 +38 -29
- 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 +38 -29
- 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 +38 -29
- 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 +38 -29
- 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/src/Utils.d.ts +6 -2
- package/package.json +9 -9
- package/src/CommonUtil.ts +36 -31
- package/src/Utils.ts +7 -2
package/dist/index.iife.js
CHANGED
|
@@ -313,38 +313,44 @@ var Utils = (function () {
|
|
|
313
313
|
if (target == null) {
|
|
314
314
|
target = {};
|
|
315
315
|
}
|
|
316
|
+
// 当前遍历的目标对象
|
|
317
|
+
let iteratorTarget;
|
|
316
318
|
if (isAdd) {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
const targetValue = Reflect.get(target, targetKeyName);
|
|
320
|
-
const sourceValue = Reflect.get(source, sourceKeyName);
|
|
321
|
-
if (typeof sourceValue === "object" &&
|
|
322
|
-
sourceValue != null &&
|
|
323
|
-
sourceKeyName in target &&
|
|
324
|
-
!UtilsContext.isDOM(sourceValue)) {
|
|
325
|
-
/* 源端的值是object类型,且不是元素节点 */
|
|
326
|
-
Reflect.set(target, sourceKeyName, UtilsContext.assign(targetValue, sourceValue, isAdd));
|
|
327
|
-
continue;
|
|
328
|
-
}
|
|
329
|
-
Reflect.set(target, sourceKeyName, sourceValue);
|
|
330
|
-
}
|
|
319
|
+
// 追加并覆盖是以source为准
|
|
320
|
+
iteratorTarget = source;
|
|
331
321
|
}
|
|
332
322
|
else {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
323
|
+
// 覆盖以target为准
|
|
324
|
+
iteratorTarget = target;
|
|
325
|
+
}
|
|
326
|
+
for (const keyName in iteratorTarget) {
|
|
327
|
+
if (!isAdd && !(keyName in source)) {
|
|
328
|
+
// 仅替换 但是源端没有此键
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
const targetValue = Reflect.get(target, keyName);
|
|
332
|
+
const sourceValue = Reflect.get(source, keyName);
|
|
333
|
+
if (typeof sourceValue === "object" &&
|
|
334
|
+
sourceValue != null &&
|
|
335
|
+
keyName in target &&
|
|
336
|
+
!UtilsContext.isDOM(sourceValue)) {
|
|
337
|
+
// 源端的值是object类型,且不是元素节点
|
|
338
|
+
// 如果是数组,那此数组中有值,清空旧的数组再赋值
|
|
339
|
+
let childObjectValue;
|
|
340
|
+
if (Array.isArray(sourceValue)) {
|
|
341
|
+
if (Array.isArray(targetValue)) {
|
|
342
|
+
targetValue.length = 0;
|
|
344
343
|
}
|
|
345
|
-
|
|
346
|
-
Reflect.set(target, targetKeyName, sourceValue);
|
|
344
|
+
childObjectValue = sourceValue;
|
|
347
345
|
}
|
|
346
|
+
else {
|
|
347
|
+
childObjectValue = UtilsContext.assign(targetValue, sourceValue, isAdd);
|
|
348
|
+
}
|
|
349
|
+
Reflect.set(target, keyName, childObjectValue);
|
|
350
|
+
}
|
|
351
|
+
else {
|
|
352
|
+
/* 直接赋值 */
|
|
353
|
+
Reflect.set(target, keyName, sourceValue);
|
|
348
354
|
}
|
|
349
355
|
}
|
|
350
356
|
return target;
|
|
@@ -441,6 +447,9 @@ var Utils = (function () {
|
|
|
441
447
|
}
|
|
442
448
|
toJSON(data, errorCallBack) {
|
|
443
449
|
let result = {};
|
|
450
|
+
if (data == null) {
|
|
451
|
+
return result;
|
|
452
|
+
}
|
|
444
453
|
if (typeof data === "object") {
|
|
445
454
|
return data;
|
|
446
455
|
}
|
|
@@ -5493,7 +5502,7 @@ var Utils = (function () {
|
|
|
5493
5502
|
}
|
|
5494
5503
|
const domUtils = new DOMUtils();
|
|
5495
5504
|
|
|
5496
|
-
const version = "2.9.
|
|
5505
|
+
const version = "2.9.8";
|
|
5497
5506
|
|
|
5498
5507
|
class Utils {
|
|
5499
5508
|
windowApi;
|
|
@@ -8031,7 +8040,7 @@ var Utils = (function () {
|
|
|
8031
8040
|
}
|
|
8032
8041
|
}
|
|
8033
8042
|
/**
|
|
8034
|
-
*
|
|
8043
|
+
* 深度获取对象的某个属性
|
|
8035
8044
|
* @param target 待获取的对象
|
|
8036
8045
|
* @param handler 获取属性的回调
|
|
8037
8046
|
*/
|