Skip to content

Commit

Permalink
fix: added some nullchecks
Browse files Browse the repository at this point in the history
  • Loading branch information
ckotzbauer committed Sep 22, 2021
1 parent 64a3ac4 commit f73e5d9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions dist/simple-tree-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@
this.allNodes = this.displayedNodes;
}
normalizeNodes(nodes) {
return nodes.map((node) => {
return nodes.filter((node) => !!node).map((node) => {
const n = this.copyNode(node);
n.uid = this.generateUid(node.value);
this.mutateNode(n);
Expand Down Expand Up @@ -600,9 +600,10 @@
filterNodes(nodes, parentMatch, searchTerm, searchMode) {
const filtered = [];
nodes.forEach((n) => {
var _a, _b;
const textOrParentMatch = searchMode === "OnlyMatches"
? n.label.toLowerCase().includes(searchTerm)
: n.label.toLowerCase().includes(searchTerm) || parentMatch;
? (_a = n.label) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(searchTerm)
: ((_b = n.label) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(searchTerm)) || parentMatch;
const childNodes = this.filterNodes(n.children, textOrParentMatch, searchTerm, searchMode);
if (textOrParentMatch || childNodes.length > 0) {
const node = this.copyNode(n);
Expand Down
Loading

0 comments on commit f73e5d9

Please sign in to comment.