mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-22 16:56:35 +00:00
Love: Fix config parsing in hui-glance-card (#1364)
* Fix config parsing in hui-glance-card * Don't modify config.
This commit is contained in:
parent
5b67a3691a
commit
05816374a8
@ -86,8 +86,6 @@ class HuiGlanceCard extends LocalizeMixin(EventsMixin(PolymerElement)) {
|
||||
}
|
||||
|
||||
_computeEntities(config) {
|
||||
const entities = computeConfigEntities(config);
|
||||
|
||||
if (!validateEntitiesConfig(config)) {
|
||||
const error = 'Error in card configuration.';
|
||||
this._error = createErrorCardConfig(error, config);
|
||||
@ -95,7 +93,7 @@ class HuiGlanceCard extends LocalizeMixin(EventsMixin(PolymerElement)) {
|
||||
}
|
||||
|
||||
this._error = null;
|
||||
return entities;
|
||||
return computeConfigEntities(config);
|
||||
}
|
||||
|
||||
_showEntity(item, states) {
|
||||
|
@ -13,6 +13,11 @@ export default function validateEntitiesConfig(config, additionalKeys = []) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return entities.every(entity => entity && typeof entity === 'object' && !Array.isArray(entity) &&
|
||||
'entity' in entity && validEntityId(entity.entity) && additionalKeys.every(key => key in entity));
|
||||
return entities.every(entity => {
|
||||
if (typeof entity === 'string') {
|
||||
return validEntityId(entity) && !additionalKeys.length;
|
||||
}
|
||||
return entity && typeof entity === 'object' && !Array.isArray(entity) &&
|
||||
'entity' in entity && validEntityId(entity.entity) && additionalKeys.every(key => key in entity)
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user