diff --git a/HISTORY.md b/HISTORY.md index 4e62aab..39e9d7c 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -6,6 +6,8 @@ https://github.com/josdejong/jsoneditor ## not yet released, version 5.23.0 - Implemented support for custom validation using a new `onValidate` callback. +- In tree mode, nodes containing a validation error now have a className + `jsoneditor-validation-error` which can be used for custom styling. ## 2018-08-13, version 5.22.0 diff --git a/src/js/Node.js b/src/js/Node.js index 494ff63..d2e5206 100644 --- a/src/js/Node.js +++ b/src/js/Node.js @@ -251,7 +251,7 @@ Node.prototype.setError = function (error, child) { this.errorChild = child; if (this.dom && this.dom.tr) { - this.updateError() + this.updateError(); } }; @@ -262,6 +262,8 @@ Node.prototype.updateError = function() { var error = this.error; var tdError = this.dom.tdError; if (error && this.dom && this.dom.tr) { + util.addClassName(this.dom.tr, 'jsoneditor-validation-error'); + if (!tdError) { tdError = document.createElement('td'); this.dom.tdError = tdError; @@ -317,6 +319,8 @@ Node.prototype.updateError = function() { tdError.appendChild(button); } else { + util.removeClassName(this.dom.tr, 'jsoneditor-validation-error'); + if (tdError) { this.dom.tdError.parentNode.removeChild(this.dom.tdError); delete this.dom.tdError;