From 7d2d669191d0d196e60bd08274cf8bbdf55a242d Mon Sep 17 00:00:00 2001 From: jos Date: Wed, 17 Oct 2018 14:50:47 +0200 Subject: [PATCH] Fixed #590: validation failing in code and text mode when status bar is disabled --- HISTORY.md | 6 ++++-- src/js/textmode.js | 12 +++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 1e1f6ca..5f549ea 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -5,8 +5,10 @@ https://github.com/josdejong/jsoneditor ## not yet released, version 5.24.8 -- Fixed #589: when deleting or moving a node, the navigation bar - is not updated with the correct path. +- Fixed #590: validation failing in code and text mode when status + bar is disabled. +- Fixed #589: the path in the navigation bar is not updated + when deleting a node. ## 2018-10-08, version 5.24.7 diff --git a/src/js/textmode.js b/src/js/textmode.js index 721bbf4..9acfc6f 100644 --- a/src/js/textmode.js +++ b/src/js/textmode.js @@ -725,19 +725,25 @@ textmode.validate = function () { var json; try { json = this.get(); // this can fail when there is no valid json - this.parseErrorIndication.style.display = 'none'; + if (this.parseErrorIndication) { + this.parseErrorIndication.style.display = 'none'; + } doValidate = true; } catch (err) { if (this.getText()) { - this.parseErrorIndication.style.display = 'block'; + if (this.parseErrorIndication) { + this.parseErrorIndication.style.display = 'block'; + } // try to extract the line number from the jsonlint error message var match = /\w*line\s*(\d+)\w*/g.exec(err.message); var line; if (match) { line = +match[1]; } - this.parseErrorIndication.title = !isNaN(line) ? ('parse error on line ' + line) : 'parse error - check that the json is valid'; + if (this.parseErrorIndication) { + this.parseErrorIndication.title = !isNaN(line) ? ('parse error on line ' + line) : 'parse error - check that the json is valid'; + } parseErrors.push({ type: 'error', message: err.message.replace(/\n/g, '
'),