diff --git a/lib/elements/dom-if.js b/lib/elements/dom-if.js index 5b801856af..dd54017c4a 100644 --- a/lib/elements/dom-if.js +++ b/lib/elements/dom-if.js @@ -210,7 +210,6 @@ class DomIfBase extends PolymerElement { // No template found yet return; } - this.__syncHostProperties(); } else if (this.restamp) { this.__teardownInstance(); } @@ -255,6 +254,12 @@ class DomIfFast extends DomIfBase { // (and any nested template effects) when the `if` is false templateInfo.runEffects = (runEffects, changedProps) => { if (this.if) { + const invalidProps = this.__invalidProps; + if (invalidProps) { + this.__squelchedRunEffects = this.__invalidProps = null; + this._showHideChildren(); + changedProps = Object.assign(invalidProps, changedProps); + } runEffects(changedProps); } else { this.__invalidProps = Object.assign(this.__invalidProps || {}, changedProps); @@ -267,10 +272,10 @@ class DomIfFast extends DomIfBase { } __syncHostProperties() { - const runEffects = this.__squelchedRunEffects; - if (runEffects) { - runEffects(this.__invalidProps); - this.__syncProps = this.__squelchedRunEffects = null; + const props = this.__invalidProps; + if (props) { + this.__squelchedRunEffects(this.__invalidProps); + this.__invalidProps = this.__squelchedRunEffects = null; } } @@ -295,6 +300,9 @@ class DomIfFast extends DomIfBase { if (this.__instance) { showHideChildren(hidden, this.__instance.templateInfo.childNodes); } + if (!hidden) { + this.__syncHostProperties(); + } } } @@ -391,6 +399,9 @@ class DomIfLegacy extends DomIfBase { const hidden = this.__hideTemplateChildren__ || !this.if; if (this.__instance) { this.__instance._showHideChildren(hidden); + if (!hidden) { + this.__syncHostProperties(); + } } } } diff --git a/lib/utils/templatize.js b/lib/utils/templatize.js index 2f075f0442..c6d0e3fb82 100644 --- a/lib/utils/templatize.js +++ b/lib/utils/templatize.js @@ -641,8 +641,10 @@ function warnOnUndeclaredProperties(templateInfo, options, methodHost) { * model.set('item.checked', true); * } * - * @param {HTMLTemplateElement} template The model will be returned for - * elements stamped from this template + * @param {HTMLElement} template The model will be returned for + * elements stamped from this template (accepts either an HTMLTemplateElement) + * or a ``/`` element when using `removeNestedTemplates` + * optimization. * @param {Node=} node Node for which to return a template model. * @return {TemplateInstanceBase} Template instance representing the * binding scope for the element