From 215217f65226b8e6d997f9c6681029af1f4d987a Mon Sep 17 00:00:00 2001 From: Andrey Date: Wed, 15 Mar 2017 06:57:11 +0200 Subject: [PATCH] On Safari 10 constructor check is broken (#237) * On Safari 10 constructor check is broken. * Move useragent check * Make custom element load unconditionally * Update state-card-content.html --- src/state-summary/state-card-content.html | 30 +++++++---------------- 1 file changed, 9 insertions(+), 21 deletions(-) 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); }