Skip to content

Commit 71254c3

Browse files
authored
[toc2] History navigation - Correct bug on empty history
1 parent ee9eed5 commit 71254c3

File tree

1 file changed

+4
-2
lines changed
  • src/jupyter_contrib_nbextensions/nbextensions/toc2

1 file changed

+4
-2
lines changed

src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,10 @@
136136
evt.preventDefault();
137137
// Each time a link is clicked in the toc, save the current position and target in the history
138138
var currentSection = $('#toc .highlight_on_scroll a').data('tocModifiedId')
139-
if (window.history.state.back != currentSection) {
140-
window.history.pushState({'back':currentSection},"",'')
139+
if (window.history.state != null){
140+
if (window.history.state.back != currentSection) {
141+
window.history.pushState({'back':currentSection},"",'')
142+
}
141143
}
142144
var trg_id = $(evt.currentTarget).attr('data-toc-modified-id');
143145
window.history.pushState({'back':trg_id},"",'');

0 commit comments

Comments
 (0)