mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 19:26:36 +00:00
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
This commit is contained in:
parent
de1b20b70a
commit
215217f652
@ -35,26 +35,14 @@ Polymer({
|
|||||||
'inputChanged(hass, inDialog, stateObj)',
|
'inputChanged(hass, inDialog, stateObj)',
|
||||||
],
|
],
|
||||||
|
|
||||||
_isLoaded: function (name) {
|
_ensureCustomUILoaded: function (stateType) {
|
||||||
var elem = document.createElement(name);
|
this.importHref(
|
||||||
// If Polymer was already loaded for <name> - it replaced the constructor.
|
'/local/custom_ui/state-card-' + stateType + '.html',
|
||||||
return (elem.constructor !== HTMLElement);
|
function () {},
|
||||||
},
|
/* eslint-disable no-console */
|
||||||
|
function () { console.error('Error loading %s from /local/custom_ui/state-card-%s.html', stateType, stateType); },
|
||||||
_maybeLoadCustomUi: function (stateType) {
|
/* eslint-enable no-console */
|
||||||
var isLoaded = this._isLoaded('STATE-CARD-' + stateType.toUpperCase());
|
true);
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
inputChanged: function (hass, inDialog, stateObj) {
|
inputChanged: function (hass, inDialog, stateObj) {
|
||||||
@ -62,7 +50,7 @@ Polymer({
|
|||||||
if (!stateObj || !hass) return;
|
if (!stateObj || !hass) return;
|
||||||
if (stateObj.state !== 'unavailable' && 'custom_ui_state_card' in stateObj.attributes) {
|
if (stateObj.state !== 'unavailable' && 'custom_ui_state_card' in stateObj.attributes) {
|
||||||
stateCardType = stateObj.attributes.custom_ui_state_card;
|
stateCardType = stateObj.attributes.custom_ui_state_card;
|
||||||
this._maybeLoadCustomUi(stateCardType);
|
this._ensureCustomUILoaded(stateCardType);
|
||||||
} else {
|
} else {
|
||||||
stateCardType = window.hassUtil.stateCardType(hass, stateObj);
|
stateCardType = window.hassUtil.stateCardType(hass, stateObj);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user