Put try/catch directly around `this.editor.options.onNodeName(...)` (see #617)
This commit is contained in:
parent
1e29d2a94a
commit
8c74bc7ef9
|
@ -4468,25 +4468,25 @@ Node.prototype._escapeJSON = function (text) {
|
|||
* @private
|
||||
*/
|
||||
Node.prototype.updateNodeName = function () {
|
||||
try {
|
||||
var count = this.childs ? this.childs.length : 0;
|
||||
var nodeName;
|
||||
if (this.type === 'object' || this.type === 'array') {
|
||||
if (this.editor.options.onNodeName) {
|
||||
var count = this.childs ? this.childs.length : 0;
|
||||
var nodeName;
|
||||
if (this.type === 'object' || this.type === 'array') {
|
||||
if (this.editor.options.onNodeName) {
|
||||
try {
|
||||
nodeName = this.editor.options.onNodeName({
|
||||
path: this.getPath(),
|
||||
size: count,
|
||||
type: this.type
|
||||
});
|
||||
}
|
||||
|
||||
this.dom.value.innerHTML = (this.type === 'object')
|
||||
? '{' + (nodeName || count) + '}'
|
||||
: '[' + (nodeName || count) + ']';
|
||||
catch (err) {
|
||||
console.error('Error in onNodeName callback: ', err);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
console.error('Error in onNodeName callback: ', err);
|
||||
|
||||
this.dom.value.innerHTML = (this.type === 'object')
|
||||
? ('{' + (nodeName || count) + '}')
|
||||
: ('[' + (nodeName || count) + ']');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue