Log a clear error in the console when the returned value of `onEditable` is invalid. See #1112

This commit is contained in:
Jos de Jong 2020-09-23 15:44:04 +02:00
parent 223b78542e
commit 58f460a383
2 changed files with 14 additions and 1 deletions

View File

@ -3,6 +3,12 @@
https://github.com/josdejong/jsoneditor
## not yet published, version 9.1.2
- Log a clear error in the console when the returned value of `onEditable` is
invalid. See #1112.
## 2020-09-23, version 9.1.1
- Fix #1111: Enum dropdown not showing when using patternProperties for schema.

View File

@ -104,9 +104,16 @@ export class Node {
if (typeof editable === 'boolean') {
this.editable.field = editable
this.editable.value = editable
} else {
} else if (typeof editable === 'object' && editable !== null) {
if (typeof editable.field === 'boolean') this.editable.field = editable.field
if (typeof editable.value === 'boolean') this.editable.value = editable.value
} else {
console.error( 'Invalid return value for function onEditable. ' +
'Actual value:', editable, '.',
'Either a boolean or object { field: boolean, value: boolean } expected.')
this.editable.field = false
this.editable.value = false
}
}
}