From 2457932400e4cc290dd33d842d6966dc78eefc1e Mon Sep 17 00:00:00 2001 From: jos Date: Mon, 10 Jul 2017 19:58:34 +0200 Subject: [PATCH] Fixed JSONEditor picking the first entry of `modes` as initial mode instead of option `mode` --- HISTORY.md | 8 ++++++++ src/js/JSONEditor.js | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 5f00986..f1a701d 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -3,6 +3,14 @@ https://github.com/josdejong/jsoneditor +## 2017-07-10, version 5.8.3 + +- Fixed #429: JSONEditor no longer accepting an empty array for option + `modes`. Thanks @trystan2k. +- Fixed JSONEditor picking the first entry of `modes` as initial mode + instead of option `mode`. + + ## 2017-07-08, version 5.8.2 - Select first option from `modes` instead of `tree` when `mode` is not diff --git a/src/js/JSONEditor.js b/src/js/JSONEditor.js index 74b5e32..9b0a331 100644 --- a/src/js/JSONEditor.js +++ b/src/js/JSONEditor.js @@ -130,7 +130,7 @@ JSONEditor.prototype._create = function (container, options, json) { this.options = options || {}; this.json = json || {}; - var mode = this.options.modes && this.options.modes.length > 0 ? this.options.modes[0] : this.options.mode || 'tree'; + var mode = this.options.mode || (this.options.modes && this.options.modes[0]) || 'tree'; this.setMode(mode); };