File tree 1 file changed +15
-17
lines changed
1 file changed +15
-17
lines changed Original file line number Diff line number Diff line change @@ -38,23 +38,21 @@ export default (
38
38
}
39
39
40
40
function dig ( list : DefaultOptionType [ ] , keepAll : boolean = false ) {
41
- return list
42
- . map ( dataNode => {
43
- const children = dataNode [ fieldChildren ] ;
44
-
45
- const match = keepAll || filterOptionFunc ( searchValue , fillLegacyProps ( dataNode ) ) ;
46
- const childList = dig ( children || [ ] , match ) ;
47
-
48
- if ( match || childList . length ) {
49
- return {
50
- ...dataNode ,
51
- isLeaf : undefined ,
52
- [ fieldChildren ] : childList ,
53
- } ;
54
- }
55
- return null ;
56
- } )
57
- . filter ( node => node ) ;
41
+ return list . reduce ( ( total , dataNode ) => {
42
+ const children = dataNode [ fieldChildren ] ;
43
+
44
+ const match = keepAll || filterOptionFunc ( searchValue , fillLegacyProps ( dataNode ) ) ;
45
+ const childList = dig ( children || [ ] , match ) ;
46
+
47
+ if ( match || childList . length ) {
48
+ total . push ( {
49
+ ...dataNode ,
50
+ isLeaf : undefined ,
51
+ [ fieldChildren ] : childList ,
52
+ } ) ;
53
+ }
54
+ return total ;
55
+ } , [ ] ) ;
58
56
}
59
57
60
58
return dig ( treeData ) ;
You can’t perform that action at this time.
0 commit comments