@@ -72,7 +72,7 @@ function* treeWalker(refresh) {
7272 // Walk through the tree until we have no nodes available.
7373 while (stack .length !== 0 ) {
7474 const {
75- node: {children , id , name },
75+ node: {children = [] , id, name},
7676 nestingLevel,
7777 } = stack .pop ();
7878
@@ -93,13 +93,13 @@ function* treeWalker(refresh) {
9393
9494 // Basing on the node openness state we are deciding if we need to render
9595 // the child nodes (if they exist).
96- if (node . children .length !== 0 && isOpened) {
96+ if (children .length !== 0 && isOpened) {
9797 // Since it is a stack structure, we need to put nodes we want to render
9898 // first to the end of the stack.
99- for (let i = node . children .length - 1 ; i >= 0 ; i-- ) {
99+ for (let i = children .length - 1 ; i >= 0 ; i-- ) {
100100 stack .push ({
101101 nestingLevel: nestingLevel + 1 ,
102- node: node . children [i],
102+ node: children[i],
103103 });
104104 }
105105 }
@@ -242,7 +242,7 @@ function* treeWalker(refresh) {
242242
243243 while (stack .length !== 0 ) {
244244 const {
245- node: {children , id , name },
245+ node: {children = [] , id, name},
246246 nestingLevel,
247247 } = stack .pop ();
248248
@@ -260,11 +260,11 @@ function* treeWalker(refresh) {
260260 }
261261 : id;
262262
263- if (node . children .length !== 0 && isOpened) {
264- for (let i = node . children .length - 1 ; i >= 0 ; i-- ) {
263+ if (children .length !== 0 && isOpened) {
264+ for (let i = children .length - 1 ; i >= 0 ; i-- ) {
265265 stack .push ({
266266 nestingLevel: nestingLevel + 1 ,
267- node: node . children [i],
267+ node: children[i],
268268 });
269269 }
270270 }
0 commit comments