Skip to content

Commit

Permalink
Fix host property syncing
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Jun 24, 2019
1 parent c2f31ed commit fc693a0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
21 changes: 16 additions & 5 deletions lib/elements/dom-if.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ class DomIfBase extends PolymerElement {
// No template found yet
return;
}
this.__syncHostProperties();
} else if (this.restamp) {
this.__teardownInstance();
}
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}
}

Expand All @@ -295,6 +300,9 @@ class DomIfFast extends DomIfBase {
if (this.__instance) {
showHideChildren(hidden, this.__instance.templateInfo.childNodes);
}
if (!hidden) {
this.__syncHostProperties();
}
}
}

Expand Down Expand Up @@ -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();
}
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions lib/utils/templatize.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<dom-if>`/`<dom-repeat>` 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
Expand Down

0 comments on commit fc693a0

Please sign in to comment.