Add className `jsoneditor-validation-error` to nodes with a validation error
This commit is contained in:
parent
d57beb9f47
commit
620c5e0b89
|
@ -6,6 +6,8 @@ https://github.com/josdejong/jsoneditor
|
||||||
## not yet released, version 5.23.0
|
## not yet released, version 5.23.0
|
||||||
|
|
||||||
- Implemented support for custom validation using a new `onValidate` callback.
|
- 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
|
## 2018-08-13, version 5.22.0
|
||||||
|
|
|
@ -251,7 +251,7 @@ Node.prototype.setError = function (error, child) {
|
||||||
this.errorChild = child;
|
this.errorChild = child;
|
||||||
|
|
||||||
if (this.dom && this.dom.tr) {
|
if (this.dom && this.dom.tr) {
|
||||||
this.updateError()
|
this.updateError();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -262,6 +262,8 @@ Node.prototype.updateError = function() {
|
||||||
var error = this.error;
|
var error = this.error;
|
||||||
var tdError = this.dom.tdError;
|
var tdError = this.dom.tdError;
|
||||||
if (error && this.dom && this.dom.tr) {
|
if (error && this.dom && this.dom.tr) {
|
||||||
|
util.addClassName(this.dom.tr, 'jsoneditor-validation-error');
|
||||||
|
|
||||||
if (!tdError) {
|
if (!tdError) {
|
||||||
tdError = document.createElement('td');
|
tdError = document.createElement('td');
|
||||||
this.dom.tdError = tdError;
|
this.dom.tdError = tdError;
|
||||||
|
@ -317,6 +319,8 @@ Node.prototype.updateError = function() {
|
||||||
tdError.appendChild(button);
|
tdError.appendChild(button);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
util.removeClassName(this.dom.tr, 'jsoneditor-validation-error');
|
||||||
|
|
||||||
if (tdError) {
|
if (tdError) {
|
||||||
this.dom.tdError.parentNode.removeChild(this.dom.tdError);
|
this.dom.tdError.parentNode.removeChild(this.dom.tdError);
|
||||||
delete this.dom.tdError;
|
delete this.dom.tdError;
|
||||||
|
|
Loading…
Reference in New Issue