diff --git a/vertical-stack-in-card.js b/vertical-stack-in-card.js index 3527750..926445d 100644 --- a/vertical-stack-in-card.js +++ b/vertical-stack-in-card.js @@ -48,10 +48,12 @@ class VerticalStackInCard extends HTMLElement { }); } card.appendChild(cardContent); - while (this.hasChildNodes()) { - this.removeChild(this.lastChild); + + const shadowRoot = this.shadowRoot || this.attachShadow({mode: 'open'}); + while (shadowRoot.hasChildNodes()) { + shadowRoot.removeChild(shadowRoot.lastChild); } - this.appendChild(card); + shadowRoot.appendChild(card); // Calculate card size this._cardSize.resolve();