Permalink
Browse files

fixed bug with split of undefined in navigation.js

  • Loading branch information...
maxkoryukov committed Feb 19, 2017
1 parent cb75453 commit 811fcca17fcc84ad9ff3f940a4194dbffa62a31d
Showing with 13 additions and 1 deletion.
  1. +13 −1 src/js/theme/navigation.js
View
@@ -142,7 +142,19 @@ function setChapterActive($chapter, hash) {
// Return the hash of link for a chapter
function getChapterHash($chapter) {
var $link = $chapter.children('a'),
- hash = $link.attr('href').split('#')[1];
+ hash,
+ href,
+ parts;
+
+ if ($link.length) {
+ href = $link.attr('href')
+ if (href) {
+ parts = href.split('#');
+ if (parts.length>1) {
+ hash = parts[1];
+ }
+ }
+ }
if (hash) hash = '#'+hash;
return (!!hash)? hash : '';

0 comments on commit 811fcca

Please sign in to comment.