From 3ad5c9f9c1b6b0af584cc7ba6841f97f0011debf Mon Sep 17 00:00:00 2001 From: jos Date: Mon, 17 Feb 2020 20:08:16 +0100 Subject: [PATCH] Fix #908: editor throwing an exception when switching from `'preview'` to `'code'` mode --- HISTORY.md | 6 ++++++ docs/api.md | 2 +- src/js/previewmode.js | 6 ++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 87a8e63..6e4560e 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -3,6 +3,12 @@ https://github.com/josdejong/jsoneditor +## not yet published, version 8.6.1 + +- Fix #908: editor throwing an exception when switching from `'preview'` + to `'code'` mode. + + ## 2020-02-16, version 8.6.0 - Fixed #906: Implemented turning Python objects containing `True`, `False` diff --git a/docs/api.md b/docs/api.md index 6310649..ef47c3c 100644 --- a/docs/api.md +++ b/docs/api.md @@ -230,7 +230,7 @@ Constructs a new JSONEditor. - `{boolean} history` - Enables history, adds a button Undo and Redo to the menu of the JSONEditor. `true` by default. Only applicable when `mode` is 'tree' or 'form'. + Enables history, adds a button Undo and Redo to the menu of the JSONEditor. `true` by default. Only applicable when `mode` is `'tree'`, `'form'`, or `'preview'`. - `{String} mode` diff --git a/src/js/previewmode.js b/src/js/previewmode.js index 7b3c6be..c5dc994 100644 --- a/src/js/previewmode.js +++ b/src/js/previewmode.js @@ -424,8 +424,10 @@ previewmode.destroy = function () { this._debouncedValidate = null - this.history.clear() - this.history = null + if (this.history) { + this.history.clear() + this.history = null + } // Removing the FocusTracker set to track the editor's focus event this.frameFocusTracker.destroy()