Prevent old more info control to be created (#7324)

This commit is contained in:
Bram Kragten 2020-10-17 22:04:44 +02:00 committed by GitHub
parent 288bf6805a
commit 5740b018a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 21 deletions

View File

@ -10,10 +10,7 @@ export const dynamicElement = directive(
let element = part.value as HTMLElement | undefined;
if (
element !== undefined &&
tag.toUpperCase() === (element as HTMLElement).tagName
) {
if (tag === element?.localName) {
if (properties) {
Object.entries(properties).forEach(([key, value]) => {
element![key] = value;

View File

@ -70,8 +70,21 @@ export class MoreInfoDialog extends LitElement {
this._entityId = params.entityId;
if (!this._entityId) {
this.closeDialog();
return;
}
this.large = false;
const stateObj = this.hass.states[this._entityId];
if (!stateObj) {
return;
}
if (stateObj.attributes && "custom_ui_more_info" in stateObj.attributes) {
this._moreInfoType = stateObj.attributes.custom_ui_more_info;
} else {
const type = stateMoreInfoType(stateObj);
importMoreInfoControl(type);
this._moreInfoType = type === "hidden" ? undefined : `more-info-${type}`;
}
}
public closeDialog() {
@ -94,23 +107,6 @@ export class MoreInfoDialog extends LitElement {
return false;
}
protected updated(changedProperties) {
if (!this.hass || !this._entityId || !changedProperties.has("_entityId")) {
return;
}
const stateObj = this.hass.states[this._entityId];
if (!stateObj) {
return;
}
if (stateObj.attributes && "custom_ui_more_info" in stateObj.attributes) {
this._moreInfoType = stateObj.attributes.custom_ui_more_info;
} else {
const type = stateMoreInfoType(stateObj);
importMoreInfoControl(type);
this._moreInfoType = type === "hidden" ? undefined : `more-info-${type}`;
}
}
protected render() {
if (!this._entityId) {
return html``;