@tmagic/utils 1.6.0-beta.1 → 1.6.0-beta.2
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/tmagic-utils.js +8 -2
- package/dist/tmagic-utils.umd.cjs +8 -2
- package/package.json +2 -2
- package/src/index.ts +9 -2
package/dist/tmagic-utils.js
CHANGED
|
@@ -329,8 +329,14 @@ const replaceChildNode = (newNode, data, parentId) => {
|
|
|
329
329
|
if (parentId) {
|
|
330
330
|
parent = getNodePath(parentId, data).pop();
|
|
331
331
|
}
|
|
332
|
-
if (!node)
|
|
333
|
-
|
|
332
|
+
if (!node) {
|
|
333
|
+
console.warn(`未找到目标节点(${newNode.id})`);
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
if (!parent) {
|
|
337
|
+
console.warn(`未找到父节点(${newNode.id})`);
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
334
340
|
const index = parent.items?.findIndex((child) => child.id === node.id);
|
|
335
341
|
parent.items.splice(index, 1, newNode);
|
|
336
342
|
};
|
|
@@ -2702,8 +2702,14 @@
|
|
|
2702
2702
|
if (parentId) {
|
|
2703
2703
|
parent = getNodePath(parentId, data).pop();
|
|
2704
2704
|
}
|
|
2705
|
-
if (!node)
|
|
2706
|
-
|
|
2705
|
+
if (!node) {
|
|
2706
|
+
console.warn(`未找到目标节点(${newNode.id})`);
|
|
2707
|
+
return;
|
|
2708
|
+
}
|
|
2709
|
+
if (!parent) {
|
|
2710
|
+
console.warn(`未找到父节点(${newNode.id})`);
|
|
2711
|
+
return;
|
|
2712
|
+
}
|
|
2707
2713
|
const index = parent.items?.findIndex((child) => child.id === node.id);
|
|
2708
2714
|
parent.items.splice(index, 1, newNode);
|
|
2709
2715
|
};
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.6.0-beta.
|
|
2
|
+
"version": "1.6.0-beta.2",
|
|
3
3
|
"name": "@tmagic/utils",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/tmagic-utils.umd.cjs",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"typescript": "^5.8.3",
|
|
37
|
-
"@tmagic/schema": "1.6.0-beta.
|
|
37
|
+
"@tmagic/schema": "1.6.0-beta.2"
|
|
38
38
|
},
|
|
39
39
|
"peerDependenciesMeta": {
|
|
40
40
|
"typescript": {
|
package/src/index.ts
CHANGED
|
@@ -380,8 +380,15 @@ export const replaceChildNode = (newNode: MNode, data?: MNode[], parentId?: Id):
|
|
|
380
380
|
parent = getNodePath(parentId, data).pop();
|
|
381
381
|
}
|
|
382
382
|
|
|
383
|
-
if (!node)
|
|
384
|
-
|
|
383
|
+
if (!node) {
|
|
384
|
+
console.warn(`未找到目标节点(${newNode.id})`);
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
if (!parent) {
|
|
389
|
+
console.warn(`未找到父节点(${newNode.id})`);
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
385
392
|
|
|
386
393
|
const index = parent.items?.findIndex((child: MNode) => child.id === node.id);
|
|
387
394
|
parent.items.splice(index, 1, newNode);
|