Skip to content

Commit 1e29d2a

Browse files
committed
Check whether onNodeName is defined before calling the function (see #617)
1 parent 535a47c commit 1e29d2a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/js/Node.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4472,11 +4472,14 @@ Node.prototype.updateNodeName = function () {
44724472
var count = this.childs ? this.childs.length : 0;
44734473
var nodeName;
44744474
if (this.type === 'object' || this.type === 'array') {
4475-
nodeName = this.editor.options.onNodeName({
4476-
path: this.getPath(),
4477-
size: count,
4478-
type: this.type
4479-
});
4475+
if (this.editor.options.onNodeName) {
4476+
nodeName = this.editor.options.onNodeName({
4477+
path: this.getPath(),
4478+
size: count,
4479+
type: this.type
4480+
});
4481+
}
4482+
44804483
this.dom.value.innerHTML = (this.type === 'object')
44814484
? '{' + (nodeName || count) + '}'
44824485
: '[' + (nodeName || count) + ']';

0 commit comments

Comments
 (0)