From f57e2334c8d823f1d5ca72db577201ad78c02b97 Mon Sep 17 00:00:00 2001 From: Andrey Date: Sun, 6 Aug 2017 00:02:49 +0300 Subject: [PATCH] Polymer2 fixes (#376) * Set all attributes together. * Revert "Set all attributes together." This reverts commit 00fe75ce4b78c17481bac45db0536169695f1f91. * Set all attributes together. * Workaround for justified on Polymer2 --- panels/config/ha-entity-config.html | 4 ++++ src/components/ha-sidebar.html | 4 ++++ src/state-summary/state-card-script.html | 4 ++++ src/util/hass-util.html | 12 +++++++++--- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/panels/config/ha-entity-config.html b/panels/config/ha-entity-config.html index 9997b3e913..2ed361f1cf 100644 --- a/panels/config/ha-entity-config.html +++ b/panels/config/ha-entity-config.html @@ -24,6 +24,10 @@ @apply(--layout-horizontal); @apply(--layout-justified); } + + dom-if { + display: none; + }
diff --git a/src/components/ha-sidebar.html b/src/components/ha-sidebar.html index edb24d593c..195c2aa1ff 100644 --- a/src/components/ha-sidebar.html +++ b/src/components/ha-sidebar.html @@ -93,6 +93,10 @@ padding: 0 8px; opacity: var(--dark-secondary-opacity); } + + dom-if { + display: none; + } diff --git a/src/state-summary/state-card-script.html b/src/state-summary/state-card-script.html index b28b1263ff..f6a7023d36 100644 --- a/src/state-summary/state-card-script.html +++ b/src/state-summary/state-card-script.html @@ -22,6 +22,10 @@ ha-entity-toggle { margin-left: 16px; } + + dom-if { + display: none; + }
diff --git a/src/util/hass-util.html b/src/util/hass-util.html index ddcd320645..f9fe871589 100644 --- a/src/util/hass-util.html +++ b/src/util/hass-util.html @@ -106,9 +106,15 @@ window.hassUtil.dynamicContentUpdater = function (root, newElementTag, attribute customEl = document.createElement(newElementTag); } - Object.keys(attributes).forEach(function (key) { - customEl[key] = attributes[key]; - }); + if (customEl.setProperties) { + customEl.setProperties(attributes); + } else { + // If custom element definition wasn't loaded yet - setProperties would be + // missing, but no harm in setting attributes one-by-one then. + Object.keys(attributes).forEach((key) => { + customEl[key] = attributes[key]; + }); + } if (customEl.parentNode === null) { rootEl.appendChild(customEl);