Skip to content

Commit b75a2a1

Browse files
committed
Fix depth
1 parent 6b49b02 commit b75a2a1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

toc.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ var TableOfContents = Control.extend({
3333
this.scroller = document.body;
3434
this.container = this.element.parentNode;
3535

36-
this.depth = window.docObject.outline && window.docObject.outline.depth || 1;
36+
var depth = window.docObject.outline && window.docObject.outline.depth;
37+
this.depth = typeof depth === "number" ? depth : 1;
3738

3839
this.navHeight = this.getNavHeight();
3940
this.titles = this.collectTitles();
@@ -94,7 +95,7 @@ var TableOfContents = Control.extend({
9495
return "article " + h;
9596
}).join(",");
9697

97-
var titles = document.querySelectorAll(selector);
98+
var titles = selector ? document.querySelectorAll(selector) : [];
9899
var curScroll = this.scroller.scrollTop;
99100
var navHeight = this.navHeight;
100101
return [].map.call(titles, function(title, idx){

0 commit comments

Comments
 (0)