From 0e5047e75daae30b2ed2c31b4734e6ba191ebb30 Mon Sep 17 00:00:00 2001 From: Min RK Date: Mon, 12 Sep 2016 14:42:48 +0200 Subject: [PATCH] allow returning full class config data, merged with defaults and merge object config values with defaults (e.g. Cell.cm_config) --- notebook/static/services/config.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/notebook/static/services/config.js b/notebook/static/services/config.js index 9c5d7dda8..822306d9f 100644 --- a/notebook/static/services/config.js +++ b/notebook/static/services/config.js @@ -102,7 +102,21 @@ function(utils) { */ ConfigWithDefaults.prototype.get_sync = function(key) { var data = this._class_data(); - return key in data ? data[key] : this.defaults[key]; + if (key === undefined) { + // no key specified, return full config data + return $.extend(true, {}, this.defaults, data); + } + + var value = data[key]; + if (value !== undefined) { + if (typeof value == 'object') { + // merge with defaults if it's an object + return $.extend(true, {}, this.defaults[key], value); + } else { + return value; + } + } + return this.defaults[key]; }; /**