mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
prevent a crash if a doclet has an empty longname
This commit is contained in:
parent
c2d3d0041b
commit
d09c654d36
@ -9,6 +9,8 @@
|
||||
var _ = require('underscore');
|
||||
var escape = require('escape-string-regexp');
|
||||
|
||||
var hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
|
||||
/**
|
||||
* Longnames that have a special meaning in JSDoc.
|
||||
*
|
||||
@ -315,20 +317,32 @@ exports.longnamesToTree = function longnamesToTree(longnames, doclets) {
|
||||
var tree = {};
|
||||
|
||||
longnames.forEach(function(longname) {
|
||||
var processed = splitLongname(longname, splitOptions);
|
||||
var nameInfo = processed.nameInfo;
|
||||
var chunk;
|
||||
var currentLongname = '';
|
||||
var currentNavItem = tree;
|
||||
var nameInfo;
|
||||
var processed;
|
||||
|
||||
// don't try to add empty longnames to the tree
|
||||
if (!longname) {
|
||||
return;
|
||||
}
|
||||
|
||||
processed = splitLongname(longname, splitOptions);
|
||||
nameInfo = processed.nameInfo;
|
||||
|
||||
processed.chunks.forEach(function(chunk) {
|
||||
currentLongname += chunk;
|
||||
|
||||
currentNavItem[chunk] = currentNavItem[chunk] || nameInfo[currentLongname];
|
||||
currentNavItem[chunk].doclet = doclets ? doclets[currentLongname] : null;
|
||||
currentNavItem[chunk].children = currentNavItem[chunk].children || {};
|
||||
if (!hasOwnProp.call(currentNavItem, chunk)) {
|
||||
currentNavItem[chunk] = nameInfo[currentLongname];
|
||||
}
|
||||
|
||||
currentNavItem = currentNavItem[chunk].children;
|
||||
if (currentNavItem[chunk]) {
|
||||
currentNavItem[chunk].doclet = doclets ? doclets[currentLongname] : null;
|
||||
currentNavItem[chunk].children = currentNavItem[chunk].children || {};
|
||||
currentNavItem = currentNavItem[chunk].children;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user