From 402afe92e2add5ad8f054daf5409185be9a135d4 Mon Sep 17 00:00:00 2001 From: jos Date: Sat, 12 May 2018 16:27:33 +0200 Subject: [PATCH] Fixed changing type of object to array and vice versa --- src/js/Node.js | 14 +++++++++----- src/js/showMoreNodeFactory.js | 4 +++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/js/Node.js b/src/js/Node.js index 28357e8..37a9bd5 100644 --- a/src/js/Node.js +++ b/src/js/Node.js @@ -579,21 +579,23 @@ Node.prototype._getNextTr = function() { /** * Hide the node with all its childs + * @param {{resetMaxVisibleChilds: boolean}} [options] */ -Node.prototype.hide = function() { +Node.prototype.hide = function(options) { var tr = this.dom.tr; var table = tr ? tr.parentNode : undefined; if (table) { table.removeChild(tr); } - this.hideChilds(); + this.hideChilds(options); }; /** * Recursively hide all childs + * @param {{resetMaxVisibleChilds: boolean}} [options] */ -Node.prototype.hideChilds = function() { +Node.prototype.hideChilds = function(options) { var childs = this.childs; if (!childs) { return; @@ -620,7 +622,9 @@ Node.prototype.hideChilds = function() { } // reset max visible childs - delete this.maxVisibleChilds; + if (!options || options.resetMaxVisibleChilds) { + delete this.maxVisibleChilds; + } }; @@ -1136,7 +1140,7 @@ Node.prototype.changeType = function (newType) { var nextTr = (lastTr && lastTr.parentNode) ? lastTr.nextSibling : undefined; // hide current field and all its childs - this.hide(); + this.hide({ resetMaxVisibleChilds: false }); this.clearDom(); // adjust the field and the value diff --git a/src/js/showMoreNodeFactory.js b/src/js/showMoreNodeFactory.js index efea8d3..10b0ba3 100644 --- a/src/js/showMoreNodeFactory.js +++ b/src/js/showMoreNodeFactory.js @@ -101,7 +101,9 @@ function showMoreNodeFactory(Node) { if (!this.dom.tr.parentNode) { var nextTr = this.parent._getNextTr(); - nextTr.parentNode.insertBefore(this.dom.tr, nextTr); + if (nextTr) { + nextTr.parentNode.insertBefore(this.dom.tr, nextTr); + } } // update the counts in the text