From 6b331e6292923ae9dccc8b1df67606dec6449ee2 Mon Sep 17 00:00:00 2001 From: xuliangzhan Date: Thu, 8 Aug 2024 10:48:38 +0800 Subject: [PATCH] releases 3.5.30 --- func/toArrayTree.js | 10 ++++++++-- package.json | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/func/toArrayTree.js b/func/toArrayTree.js index d72b9c5..4cb1e82 100644 --- a/func/toArrayTree.js +++ b/func/toArrayTree.js @@ -64,10 +64,16 @@ function toArrayTree (array, options) { parentId = item[optParentKey] treeMap[id] = treeMap[id] || [] - treeMap[parentId] = treeMap[parentId] || [] - treeMap[parentId].push(treeData) treeData[optKey] = id treeData[optParentKey] = parentId + + if (id === parentId) { + parentId = null + console.log('Fix infinite Loop.', item) + } + + treeMap[parentId] = treeMap[parentId] || [] + treeMap[parentId].push(treeData) treeData[optChildren] = treeMap[id] if (optMapChildren) { treeData[optMapChildren] = treeMap[id] diff --git a/package.json b/package.json index b309dc4..c230c82 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xe-utils", - "version": "3.5.29", + "version": "3.5.30", "description": "JavaScript 函数库、工具类", "main": "index.js", "unpkg": "dist/xe-utils.umd.min.js",