From b012be62e548807adee4dd62eec26bd759539baa Mon Sep 17 00:00:00 2001 From: Jos de Jong Date: Mon, 10 May 2021 20:12:32 +0200 Subject: [PATCH] Fix #1311: exception being thrown under certain conditions when switching from `code` mode to `preview` mode --- HISTORY.md | 6 ++++++ src/js/textmode.js | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 0023f02c7..99bfbf769 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -3,6 +3,12 @@ https://github.com/josdejong/jsoneditor +## not yet published, version 9.4.2 + +- Fix #1311: exception being thrown under certain conditions when switching + from `code` mode to `preview` mode. + + ## 2021-04-25, version 9.4.1 - Improvements in the Korean translation. Thanks @luasenvy. diff --git a/src/js/textmode.js b/src/js/textmode.js index f5f6f600e..ceabe7fc4 100644 --- a/src/js/textmode.js +++ b/src/js/textmode.js @@ -412,7 +412,11 @@ textmode._onChange = function () { } // enable/disable undo/redo buttons - setTimeout(() => this._updateHistoryButtons()) + setTimeout(() => { + if (this._updateHistoryButtons) { + this._updateHistoryButtons() + } + }) // validate JSON schema (if configured) this._debouncedValidate() @@ -800,7 +804,11 @@ textmode._setText = function (jsonText, clearHistory) { }) } - setTimeout(() => this._updateHistoryButtons()) + setTimeout(() => { + if (this._updateHistoryButtons) { + this._updateHistoryButtons() + } + }) } // validate JSON schema