mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 17:26:42 +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)',
|
||||
],
|
||||
|
||||
_isLoaded: function (name) {
|
||||
var elem = document.createElement(name);
|
||||
// If Polymer was already loaded for <name> - 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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user