From 321f6fe1ea0cc6f28abc7e93747cf7ff7baf3c96 Mon Sep 17 00:00:00 2001 From: NARUTOne Date: Sat, 16 Apr 2022 15:15:25 +0800 Subject: [PATCH] fix: filterTreeFn --- CHANGELOG.md | 6 ++++++ package.json | 2 +- src/filterTreeFn.js | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd997f4..1d1d5f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ > pm log 🚀⏲ +## 0.8.2 + +`2022-04-16` + +- 🐛修复`filterTreeFn`问题 + ## 0.8.1 `2021-12-23` diff --git a/package.json b/package.json index 66833f7..3074c18 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "flo-utils", - "version": "0.8.1", + "version": "0.8.2", "description": "some utils ", "main": "lib/index.js", "module": "es/index.js", diff --git a/src/filterTreeFn.js b/src/filterTreeFn.js index f1877da..fe4fa99 100644 --- a/src/filterTreeFn.js +++ b/src/filterTreeFn.js @@ -17,7 +17,8 @@ function filterTreeFn(data, fn, childrenKey = 'children') { let newData = data.filter(fn); newData = newData.map((item) => { const x = { ...item }; - x[childrenKey] && (x[childrenKey] = filterTreeFn(x[childrenKey], fn)); + x[childrenKey] && + (x[childrenKey] = filterTreeFn(x[childrenKey], fn, childrenKey)); return x; });