mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-06 17:40:27 +00:00
Optimize demo (#2681)
This commit is contained in:
@@ -3,7 +3,6 @@ import "../custom-cards/ha-demo-card";
|
||||
// tslint:disable-next-line
|
||||
import { HADemoCard } from "../custom-cards/ha-demo-card";
|
||||
import { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
|
||||
import { HUIView } from "../../../src/panels/lovelace/hui-view";
|
||||
import { selectedDemoConfig } from "../configs/demo-configs";
|
||||
|
||||
export const mockLovelace = (hass: MockHomeAssistant) => {
|
||||
@@ -16,13 +15,17 @@ export const mockLovelace = (hass: MockHomeAssistant) => {
|
||||
hass.mockWS("lovelace/config/save", () => Promise.resolve());
|
||||
};
|
||||
|
||||
// Patch HUI-VIEW to make the lovelace object available to the demo card
|
||||
const oldCreateCard = HUIView.prototype.createCardElement;
|
||||
customElements.whenDefined("hui-view").then(() => {
|
||||
// tslint:disable-next-line
|
||||
const HUIView = customElements.get("hui-view");
|
||||
// Patch HUI-VIEW to make the lovelace object available to the demo card
|
||||
const oldCreateCard = HUIView.prototype.createCardElement;
|
||||
|
||||
HUIView.prototype.createCardElement = function(config) {
|
||||
const el = oldCreateCard.call(this, config);
|
||||
if (el.tagName === "HA-DEMO-CARD") {
|
||||
(el as HADemoCard).lovelace = this.lovelace;
|
||||
}
|
||||
return el;
|
||||
};
|
||||
HUIView.prototype.createCardElement = function(config) {
|
||||
const el = oldCreateCard.call(this, config);
|
||||
if (el.tagName === "HA-DEMO-CARD") {
|
||||
(el as HADemoCard).lovelace = this.lovelace;
|
||||
}
|
||||
return el;
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user