From ae6334f358bf3886e3bf4148175ac9055df68696 Mon Sep 17 00:00:00 2001 From: Mathieu David Date: Wed, 30 Dec 2015 17:19:43 +0100 Subject: [PATCH] Fix bug where we would not check if there was actually a page to navigate to when using arrow keys --- src/theme/book.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/theme/book.js b/src/theme/book.js index 89f71c45..9724d044 100644 --- a/src/theme/book.js +++ b/src/theme/book.js @@ -32,11 +32,15 @@ $( document ).ready(function() { switch (e.keyCode) { case KEY_CODES.NEXT_KEY: e.preventDefault(); - window.location.href = $('.nav-chapters.next').attr('href'); + if($('.nav-chapters.next').length) { + window.location.href = $('.nav-chapters.next').attr('href'); + } break; case KEY_CODES.PREVIOUS_KEY: e.preventDefault(); - window.location.href = $('.nav-chapters.previous').attr('href'); + if($('.nav-chapters.previous').length) { + window.location.href = $('.nav-chapters.previous').attr('href'); + } break; } });