Skip to content

Commit 86a790f

Browse files
committed
[toc2] only set notebook dirty if metadata item changed
ToC setting the notebook dirty every time it loaded was annoying me. This uses deep compare if underscore is available. In other cases, the shallow compare means object like toc_position will always look changed, but that's ok, as it only gets set when something gets moved anyway.
1 parent 5c077f5 commit 86a790f

File tree

1 file changed

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

1 file changed

+4
-1
lines changed

src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,11 @@
9999
if (md === undefined) {
100100
md = IPython.notebook.metadata.toc = {};
101101
}
102+
var old_val = md[key];
102103
md[key] = value;
103-
IPython.notebook.set_dirty();
104+
if (typeof _ !== undefined ? !_.isEqual(value, old_val) : old_val != value) {
105+
IPython.notebook.set_dirty();
106+
}
104107
}
105108
return value;
106109
};

0 commit comments

Comments
 (0)