diff --git a/src/state-summary/state-card-content.html b/src/state-summary/state-card-content.html index 9579908eca..8c011bfcff 100644 --- a/src/state-summary/state-card-content.html +++ b/src/state-summary/state-card-content.html @@ -35,26 +35,14 @@ Polymer({ 'inputChanged(hass, inDialog, stateObj)', ], - _isLoaded: function (name) { - var elem = document.createElement(name); - // If Polymer was already loaded for - it replaced the constructor. - return (elem.constructor !== HTMLElement); - }, - - _maybeLoadCustomUi: function (stateType) { - var isLoaded = this._isLoaded('STATE-CARD-' + stateType.toUpperCase()); - // If Polymer component for the required element is not loaded try to load it. - // Don't try to load unconditionally because it cause onflict between vulcanized - // and non-vulacanized versions. - if (!isLoaded) { - this.importHref( - '/local/custom_ui/state-card-' + stateType + '.html', - function () {}, - /* eslint-disable no-console */ - function () { console.error('Error loading %s from /local/custom_ui/state-card-%s.html', stateType, stateType); }, - /* eslint-enable no-console */ - true); - } + _ensureCustomUILoaded: function (stateType) { + this.importHref( + '/local/custom_ui/state-card-' + stateType + '.html', + function () {}, + /* eslint-disable no-console */ + function () { console.error('Error loading %s from /local/custom_ui/state-card-%s.html', stateType, stateType); }, + /* eslint-enable no-console */ + true); }, inputChanged: function (hass, inDialog, stateObj) { @@ -62,7 +50,7 @@ Polymer({ if (!stateObj || !hass) return; if (stateObj.state !== 'unavailable' && 'custom_ui_state_card' in stateObj.attributes) { stateCardType = stateObj.attributes.custom_ui_state_card; - this._maybeLoadCustomUi(stateCardType); + this._ensureCustomUILoaded(stateCardType); } else { stateCardType = window.hassUtil.stateCardType(hass, stateObj); }