mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
add fast path to hasAncestor
This commit is contained in:
parent
5b4e2c51f7
commit
db9a570e2d
@ -217,6 +217,11 @@ exports.hasAncestor = function(parent, child) {
|
||||
return hasAncestor;
|
||||
}
|
||||
|
||||
// fast path for obvious non-ancestors
|
||||
if (child.indexOf(parent) !== 0) {
|
||||
return hasAncestor;
|
||||
}
|
||||
|
||||
do {
|
||||
memberof = exports.shorten(memberof).memberof;
|
||||
|
||||
|
||||
@ -293,6 +293,12 @@ describe('jsdoc/name', function() {
|
||||
expect(hasAncestor).toBe(true);
|
||||
});
|
||||
|
||||
it('should correctly identify when a non-ancestor is passed in', function() {
|
||||
var hasAncestor = jsdoc.name.hasAncestor('module:foo', 'foo');
|
||||
|
||||
expect(hasAncestor).toBe(false);
|
||||
});
|
||||
|
||||
it('should not say that a longname is its own ancestor', function() {
|
||||
var hasAncestor = jsdoc.name.hasAncestor('module:foo', 'module:foo');
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user