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",