diff --git a/lib/elements/dom-if.js b/lib/elements/dom-if.js index 8bc21caf99..12250e4b66 100644 --- a/lib/elements/dom-if.js +++ b/lib/elements/dom-if.js @@ -464,9 +464,9 @@ class DomIfFast extends DomIfBase { if (this.__instance && Boolean(this.__instance.__hidden) !== hidden) { this.__instance.__hidden = hidden; showHideChildren(hidden, this.__instance.templateInfo.childNodes); - if (!hidden) { - this.__syncHostProperties(); - } + } + if (!hidden) { + this.__syncHostProperties(); } } } @@ -615,9 +615,9 @@ class DomIfLegacy extends DomIfBase { if (this.__instance && Boolean(this.__instance.__hidden) !== hidden) { this.__instance.__hidden = hidden; this.__instance._showHideChildren(hidden); - if (!hidden) { - this.__syncHostProperties(); - } + } + if (!hidden) { + this.__syncHostProperties(); } } } diff --git a/test/unit/dom-if.html b/test/unit/dom-if.html index 4a1b5cf75d..aa115da199 100644 --- a/test/unit/dom-if.html +++ b/test/unit/dom-if.html @@ -895,6 +895,21 @@ document.body.removeChild(el); }); + test.only('host properties in sync toggling true-false-true synchronously', function() { + let el = document.createElement('x-guard-separate-props'); + el.restamp = restamp; + document.body.appendChild(el); + el.a = 'initial'; + el.b = true; + flush(); + assert.equal(el.shadowRoot.textContent.trim(), 'initial'); + el.setProperties({b: false, a: 'changed'}); + el.b = true; + flush(); + assert.equal(el.shadowRoot.textContent.trim(), 'changed'); + document.body.removeChild(el); + }); + test('host paths in sync when changed while false', function() { let el = document.createElement('x-guard-separate-paths'); el.restamp = restamp;