Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

Commit

Permalink
Changes to work with panel:true
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasloven committed Sep 24, 2018
1 parent be361f0 commit b6818a2
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions card-modder.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,32 @@ class CardModder extends Polymer.Element {

this.card = document.createElement(tag);
this.card.setConfig(config.card);
this.appendChild(this.card);

if(this.$) this._cardMod();
}

ready() {
super.ready();
if(this._config) this._cardMod();
}

connectedCallback() {
_cardMod() {
this.appendChild(this.card);

let target = this.card;
if(this.card.shadowRoot && this.card.shadowRoot.querySelector("ha-card")) {
target = this.card.shadowRoot.querySelector("ha-card");
} else if (this.card.firstChild && this.card.firstChild.shadowRoot && this.card.firstChild.shadowRoot.querySelector("ha-card")) {
} else if(this.card.firstChild && this.card.firstChild.shadowRoot && this.card.firstChild.shadowRoot.querySelector("ha-card")) {
target = this.card.firstChild.shadowRoot.querySelector("ha-card");
}

for(var k in this._config.style) {
target.style.setProperty(k, this._config.style[k]);
}
}

set hass(hass) {
this.card.hass = hass;
if(this.card) this.card.hass = hass;
}

getCardSize() {
Expand Down

0 comments on commit b6818a2

Please sign in to comment.