Skip to content

Commit

Permalink
Fix overriding firstUpdated
Browse files Browse the repository at this point in the history
  • Loading branch information
jcwillox committed Mar 19, 2020
1 parent 39ef673 commit 3a29762
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/ha-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { extensionEnabled, findConfig } from "./utils";

customElements.whenDefined("ha-card").then(() => {
const HaCard = customElements.get("ha-card");
const firstUpdated = HaCard.prototype.firstUpdated;

HaCard.prototype.firstUpdated = function() {
firstUpdated.call(this);
const config = findConfig(this);
if (
config &&
Expand Down
3 changes: 3 additions & 0 deletions src/hui-generic-entity-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import { extensionEnabled } from "./utils";
customElements.whenDefined("hui-generic-entity-row").then(() => {
const EntityRow = customElements.get("hui-generic-entity-row");

const firstUpdated = EntityRow.prototype.firstUpdated;

EntityRow.prototype.firstUpdated = function() {
firstUpdated.call(this);
if (
this.config.secondary_info &&
extensionEnabled(this.config, "secondary_info")
Expand Down
2 changes: 2 additions & 0 deletions src/hui-glance-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { extensionEnabled } from "./utils";

customElements.whenDefined("hui-glance-card").then(() => {
const GlanceCard = customElements.get("hui-glance-card");
const firstUpdated = GlanceCard.prototype.firstUpdated;

const getAlignment = function(alignment) {
switch (alignment) {
Expand All @@ -16,6 +17,7 @@ customElements.whenDefined("hui-glance-card").then(() => {
};

GlanceCard.prototype.firstUpdated = function() {
firstUpdated.call(this);
if (this._config.align && extensionEnabled(this._config, "align")) {
this.shadowRoot.querySelector(
".entities"
Expand Down
2 changes: 2 additions & 0 deletions src/hui-warning.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { extensionEnabled, findConfig } from "./utils";

customElements.whenDefined("hui-warning").then(() => {
const WarningCard = customElements.get("hui-warning");
const firstUpdated = WarningCard.prototype.firstUpdated;

WarningCard.prototype.firstUpdated = function() {
firstUpdated.call(this);
const config = findConfig(this);
if (
config &&
Expand Down
1 change: 0 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { createCard } from "card-tools/src/lovelace-element";
import { hass } from "card-tools/src/hass";
import { applyTheme } from "./styles";
import { logVersion } from "./logging";
import { registerCard } from "card-tools/src/editor";
import { name, version } from "../package.json";
// allow dynamic updating of secondary info.
import "./secondary-info";
Expand Down
2 changes: 2 additions & 0 deletions src/vertical-stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { extensionEnabled } from "./utils";

customElements.whenDefined("hui-vertical-stack-card").then(() => {
const VerticalStack = customElements.get("hui-vertical-stack-card");
const firstUpdated = VerticalStack.prototype.firstUpdated;

const applyStyles = async function(element) {
// exit clause.
Expand All @@ -30,6 +31,7 @@ customElements.whenDefined("hui-vertical-stack-card").then(() => {
};

VerticalStack.prototype.firstUpdated = function() {
firstUpdated.call(this);
if (
this._config.in_card === true &&
extensionEnabled(this._config, "in_card")
Expand Down

0 comments on commit 3a29762

Please sign in to comment.