Skip to content

Commit

Permalink
fixed case node.children is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
stla committed Nov 27, 2023
1 parent 93e0627 commit d393f5d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions inst/htmlwidgets/jstreer.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,11 @@ function setShinyValueSelectedNodes(instance, leavesOnly, checkboxes) {
data: node.data
};
pathNodes.push(pathNode);
var nchildren = node.children.length;
delete nodes[i].children;
var hasChildren = node.children;
var nchildren = hasChildren ? node.children.length : 0;
if(hasChildren) {
delete nodes[i].children;
}
if(leavesOnly && nchildren === 0) {
leaves.push(nodes[i]);
leavePathNodes.push(pathNode);
Expand Down Expand Up @@ -131,8 +134,11 @@ function setShinyValueCheckedNodes(instance, leavesOnly) {
data: node.data
};
pathNodes.push(pathNode);
var nchildren = node.children.length;
delete nodes[i].children;
var hasChildren = node.children;
var nchildren = hasChildren ? node.children.length : 0;
if(hasChildren) {
delete nodes[i].children;
}
if(leavesOnly && nchildren === 0) {
leaves.push(nodes[i]);
leavePathNodes.push(pathNode);
Expand Down

0 comments on commit d393f5d

Please sign in to comment.