don’t create empty children objects

This commit is contained in:
Jeff Williams 2015-01-13 14:39:39 -08:00
parent fb2c36781f
commit f1b6b2dc7c

View File

@ -337,7 +337,7 @@ exports.longnamesToTree = function longnamesToTree(longnames, doclets) {
longnames.forEach(function(longname) {
var currentLongname = '';
var currentNavItem = tree;
var currentParent = tree;
var nameInfo;
var processed;
@ -352,14 +352,18 @@ exports.longnamesToTree = function longnamesToTree(longnames, doclets) {
processed.chunks.forEach(function(chunk) {
currentLongname += chunk;
if (!hasOwnProp.call(currentNavItem, chunk)) {
currentNavItem[chunk] = nameInfo[currentLongname];
if (currentParent !== tree) {
currentParent.children = currentParent.children || {};
currentParent = currentParent.children;
}
if (currentNavItem[chunk]) {
currentNavItem[chunk].doclet = doclets ? doclets[currentLongname] : null;
currentNavItem[chunk].children = currentNavItem[chunk].children || {};
currentNavItem = currentNavItem[chunk].children;
if (!hasOwnProp.call(currentParent, chunk)) {
currentParent[chunk] = nameInfo[currentLongname];
}
if (currentParent[chunk]) {
currentParent[chunk].doclet = doclets ? doclets[currentLongname] : null;
currentParent = currentParent[chunk];
}
});
});