skip checking children if it was empty

This commit is contained in:
Rijn 2017-08-09 09:29:57 -05:00
parent f3c6cd68d1
commit 173f1c0077
2 changed files with 3 additions and 2 deletions

View file

@ -29,7 +29,8 @@
},
{
title: 'child2',
id: '1-2'
id: '1-2',
children: []
}
]
}

View file

@ -71,7 +71,7 @@
// init checked status
function reverseChecked(data) {
if (!data.nodeKey) data.nodeKey = key++;
if (data.children) {
if (data.children && data.children.length) {
let checkedLength = 0;
data.children.forEach(node => {
if (node.children) node = reverseChecked(node);