From 9957634b792f7deef82047ededeb6349ccb3b1b4 Mon Sep 17 00:00:00 2001 From: haoliangyu Date: Sun, 13 Mar 2016 20:52:10 -0400 Subject: [PATCH 1/3] accept HTML DOM element object as content --- src/L.Control.Sidebar.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/L.Control.Sidebar.js b/src/L.Control.Sidebar.js index be14c3b..82248d8 100644 --- a/src/L.Control.Sidebar.js +++ b/src/L.Control.Sidebar.js @@ -161,7 +161,14 @@ L.Control.Sidebar = L.Control.extend({ }, setContent: function (content) { - this.getContainer().innerHTML = content; + if (typeof content === 'string') { + this.getContainer().innerHTML = content; + } else { + this._content = content; + } + + this.update(); + return this; }, From 940164ae3d6fed2fde1146b1907c0cda8a13f5db Mon Sep 17 00:00:00 2001 From: haoliangyu Date: Sun, 13 Mar 2016 21:29:51 -0400 Subject: [PATCH 2/3] clear previous content before appending child --- src/L.Control.Sidebar.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/L.Control.Sidebar.js b/src/L.Control.Sidebar.js index 82248d8..2e016bb 100644 --- a/src/L.Control.Sidebar.js +++ b/src/L.Control.Sidebar.js @@ -161,15 +161,20 @@ L.Control.Sidebar = L.Control.extend({ }, setContent: function (content) { - if (typeof content === 'string') { - this.getContainer().innerHTML = content; - } else { - this._content = content; - } + var container = this.getContainer(); - this.update(); - - return this; + if (typeof content === 'string') { + container.innerHTML = content; + } else { + // clean current content + while (container.firstChild) { + container.removeChild(container.firstChild); + } + + container.appendChild(content); + } + + return this; }, getOffset: function () { From 68fb35f0c63a9b29c42e53051fd9984161e90c45 Mon Sep 17 00:00:00 2001 From: haoliangyu Date: Thu, 17 Mar 2016 22:03:09 -0400 Subject: [PATCH 3/3] indentation fix --- src/L.Control.Sidebar.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/L.Control.Sidebar.js b/src/L.Control.Sidebar.js index 2e016bb..e519176 100644 --- a/src/L.Control.Sidebar.js +++ b/src/L.Control.Sidebar.js @@ -161,20 +161,20 @@ L.Control.Sidebar = L.Control.extend({ }, setContent: function (content) { - var container = this.getContainer(); + var container = this.getContainer(); - if (typeof content === 'string') { - container.innerHTML = content; - } else { - // clean current content - while (container.firstChild) { - container.removeChild(container.firstChild); - } + if (typeof content === 'string') { + container.innerHTML = content; + } else { + // clean current content + while (container.firstChild) { + container.removeChild(container.firstChild); + } - container.appendChild(content); - } + container.appendChild(content); + } - return this; + return this; }, getOffset: function () {