mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-09 02:16:35 +00:00
Fixes (#1377)
* Fix legacy wrapper in browsers without native custom elements * Better error reporting for picture-elements * Lint
This commit is contained in:
parent
54fcb21917
commit
dc5213a79a
@ -27,10 +27,8 @@ export default class LegacyWrapperCard extends HTMLElement {
|
|||||||
|
|
||||||
if (entityId in hass.states) {
|
if (entityId in hass.states) {
|
||||||
this._ensureElement(this._tag);
|
this._ensureElement(this._tag);
|
||||||
this.lastChild.setProperties({
|
this.lastChild.hass = hass;
|
||||||
hass,
|
this.lastChild.stateObj = hass.states[entityId];
|
||||||
stateObj: hass.states[entityId],
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
this._ensureElement('HUI-ERROR-CARD');
|
this._ensureElement('HUI-ERROR-CARD');
|
||||||
this.lastChild.setConfig(createErrorCardConfig(`No state available for ${entityId}`, this._config));
|
this.lastChild.setConfig(createErrorCardConfig(`No state available for ${entityId}`, this._config));
|
||||||
|
@ -14,6 +14,8 @@ import toggleEntity from '../common/entity/toggle-entity.js';
|
|||||||
import EventsMixin from '../../../mixins/events-mixin.js';
|
import EventsMixin from '../../../mixins/events-mixin.js';
|
||||||
import LocalizeMixin from '../../../mixins/localize-mixin.js';
|
import LocalizeMixin from '../../../mixins/localize-mixin.js';
|
||||||
|
|
||||||
|
const VALID_TYPES = new Set(['service-button', 'state-badge', 'state-icon', 'state-label']);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @appliesMixin EventsMixin
|
* @appliesMixin EventsMixin
|
||||||
* @appliesMixin LocalizeMixin
|
* @appliesMixin LocalizeMixin
|
||||||
@ -85,6 +87,10 @@ class HuiPictureElementsCard extends EventsMixin(LocalizeMixin(PolymerElement))
|
|||||||
if (!config || !config.image || !Array.isArray(config.elements)) {
|
if (!config || !config.image || !Array.isArray(config.elements)) {
|
||||||
throw new Error('Invalid card configuration');
|
throw new Error('Invalid card configuration');
|
||||||
}
|
}
|
||||||
|
const invalidTypes = config.elements.map(el => el.type).filter(el => !VALID_TYPES.has(el));
|
||||||
|
if (invalidTypes.length) {
|
||||||
|
throw new Error(`Incorrect element types: ${invalidTypes.join(', ')}`);
|
||||||
|
}
|
||||||
|
|
||||||
this._config = config;
|
this._config = config;
|
||||||
if (this.$) this._buildConfig();
|
if (this.$) this._buildConfig();
|
||||||
@ -106,7 +112,6 @@ class HuiPictureElementsCard extends EventsMixin(LocalizeMixin(PolymerElement))
|
|||||||
img.src = config.image;
|
img.src = config.image;
|
||||||
root.appendChild(img);
|
root.appendChild(img);
|
||||||
|
|
||||||
|
|
||||||
config.elements.forEach((element) => {
|
config.elements.forEach((element) => {
|
||||||
const entityId = element.entity;
|
const entityId = element.entity;
|
||||||
let el;
|
let el;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user