Skip to content

Commit 5a3401a

Browse files
committed
refactor return value
1 parent cc6555e commit 5a3401a

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

src/utils/strategyUtil.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,21 @@ export function formatStrategyValues(
2020
if (strategy === SHOW_CHILD) {
2121
return values.filter(key => {
2222
const entity = keyEntities[key];
23-
24-
if (
25-
entity &&
26-
entity.children &&
27-
entity.children.some(({ node }) => valueSet.has(node[fieldNames.value])) &&
28-
entity.children.every(
23+
return (
24+
!entity ||
25+
!entity.children ||
26+
!entity.children.some(({ node }) => valueSet.has(node[fieldNames.value])) ||
27+
!entity.children.every(
2928
({ node }) => isCheckDisabled(node) || valueSet.has(node[fieldNames.value]),
3029
)
31-
) {
32-
return false;
33-
}
34-
return true;
30+
);
3531
});
3632
}
3733
if (strategy === SHOW_PARENT) {
3834
return values.filter(key => {
3935
const entity = keyEntities[key];
4036
const parent = entity ? entity.parent : null;
41-
42-
if (parent && !isCheckDisabled(parent.node) && valueSet.has(parent.key)) {
43-
return false;
44-
}
45-
return true;
37+
return !parent || isCheckDisabled(parent.node) || !valueSet.has(parent.key);
4638
});
4739
}
4840
return values;

0 commit comments

Comments
 (0)