Skip to content

Commit 8eef4f0

Browse files
committed
refactor: update element creation to use await for asynchronous helpers
1 parent 492bbe2 commit 8eef4f0

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/components/shared/vsc-tire-card.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export class VehicleTireCard extends BaseElement {
3232
constructor() {
3333
super();
3434
}
35+
3536
connectedCallback(): void {
3637
super.connectedCallback();
3738
}
@@ -114,13 +115,13 @@ export class VehicleTireCard extends BaseElement {
114115
return element;
115116
}
116117

117-
private async _rebuildElement(elToReplace: LovelaceElement, config: LovelaceElementConfig): Promise<void> {
118+
private _rebuildElement = async (elToReplace: LovelaceElement, config: LovelaceElementConfig): Promise<void> => {
118119
const newCardEl = await this._createElement(config);
119120
if (elToReplace.parentElement) {
120121
elToReplace.parentElement.replaceChild(newCardEl, elToReplace);
121122
}
122123
this._elements = this._elements!.map((curCardEl) => (curCardEl === elToReplace ? newCardEl : curCardEl));
123-
}
124+
};
124125
static get styles(): CSSResultGroup {
125126
return [super.styles, css``];
126127
}

src/utils/lovelace/create-card-element.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const loadVerticalStackCard = async (): Promise<void> => {
5555
}
5656

5757
if (!customElements.get(VERTICAL_STACK_TAG)) {
58-
helpers.createCardElement({
58+
await helpers.createCardElement({
5959
type: 'vertical-stack',
6060
cards: [],
6161
});
@@ -104,7 +104,7 @@ export const loadPictureCardHelper = async (hass: HomeAssistant): Promise<void>
104104
};
105105

106106
export async function createHuiElement(elementConfig: LovelaceElementConfig): Promise<LovelaceElement> {
107-
const element = (await helpers.createHuiElement(elementConfig)) as LovelaceElement;
107+
const element = await helpers?.createHuiElement(elementConfig);
108108
if (element.tagName !== 'HUI-CONDITIONAL-ELEMENT') {
109109
element.classList.add('element');
110110
}

0 commit comments

Comments
 (0)