Skip to content

Commit 8e61312

Browse files
committed
[toc2] ensure default config values are present in non-live notebooks
1 parent 6dc75c3 commit 8e61312

File tree

1 file changed

+6
-3
lines changed
  • src/jupyter_contrib_nbextensions/nbextensions/toc2

1 file changed

+6
-3
lines changed

src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,12 @@
529529
return
530530
}
531531

532+
// In a live notebook, read_config will have been called already, but
533+
// in non-live notebooks, ensure that all config values are defined.
534+
if (!liveNotebook) {
535+
cfg = $.extend(true, {}, default_cfg, cfg);
536+
}
537+
532538
var toc_wrapper = $("#toc-wrapper");
533539
if (toc_wrapper.length === 0) { // toc window doesn't exist at all
534540
create_toc_div(cfg, st); // create it
@@ -537,9 +543,6 @@
537543
var ul = $('<ul/>').addClass('toc-item');
538544

539545
// update sidebar/window title
540-
if (typeof cfg.title_sidebar === 'undefined') { // For backwards compatibility:
541-
cfg.title_sidebar = "Contents" // May not be defined in some non-live notebooks
542-
};
543546
$('#toc-header > .header').text(cfg.title_sidebar + ' ');
544547

545548
// update toc element

0 commit comments

Comments
 (0)