Skip to content

Commit

Permalink
Put try/catch directly around this.editor.options.onNodeName(...) (…
Browse files Browse the repository at this point in the history
  • Loading branch information
josdejong committed Jan 5, 2019
1 parent 1e29d2a commit 8c74bc7
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/js/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) + ']');
}
}

Expand Down

0 comments on commit 8c74bc7

Please sign in to comment.