From a4f97b73c8d181794cc76dc28f2ab1d14df1a664 Mon Sep 17 00:00:00 2001 From: Gluwc Date: Tue, 12 Nov 2019 14:57:54 +0100 Subject: [PATCH] 1.6.2 * Added removal of lastChild when it is empty. --- bar-card.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bar-card.js b/bar-card.js index 1975bf2..9fe4a3e 100644 --- a/bar-card.js +++ b/bar-card.js @@ -4,6 +4,9 @@ class BarCard extends HTMLElement { this.attachShadow({ mode: 'open' }) } setConfig (config) { + while(this.shadowRoot.lastChild) + this.shadowRoot.removeChild(this.shadowRoot.lastChild); + // Default Card variables const initialConfig = Object.assign({}, config) @@ -1000,7 +1003,7 @@ class BarCard extends HTMLElement { } return } - + // Define config const config = this._configAttributeCheck(entity, index) @@ -1027,7 +1030,7 @@ class BarCard extends HTMLElement { } else { entityState = entityObject.state } - + if(!isNaN(entityState)){ entityState = Number(entityState) } @@ -1036,7 +1039,7 @@ class BarCard extends HTMLElement { entityState = Math.min(entityState, configMax) entityState = Math.max(entityState, configMin) } - + if (config.decimal !== false) { entityState = entityState.toFixed(config.decimal) } @@ -1223,7 +1226,7 @@ class BarCard extends HTMLElement { customElements.define('bar-card', BarCard) console.info( - `%cBAR-CARD\n%cVersion: 1.6.1`, + `%cBAR-CARD\n%cVersion: 1.6.2`, "color: green; font-weight: bold;", "" );