Skip to content

Commit

Permalink
Store syncInfo on the dom-if, but null it in teardown.
Browse files Browse the repository at this point in the history
(same as invalidProps for non-fastDomIf)
  • Loading branch information
kevinpschaaf committed Feb 21, 2020
1 parent b9bbee2 commit fe86a8c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/elements/dom-if.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ class DomIfFast extends DomIfBase {
constructor() {
super();
this.__instance = null;
this.__syncInfo = null;
}

/**
Expand Down Expand Up @@ -385,8 +386,7 @@ class DomIfFast extends DomIfBase {
// Install runEffects hook that prevents running property effects
// (and any nested template effects) when the `if` is false
templateInfo.runEffects = (runEffects, changedProps, hasPaths) => {
const instance = this.__instance;
let syncInfo = instance && instance.__syncInfo;
let syncInfo = this.__syncInfo;
if (this.if) {
// Mix any props that changed while the `if` was false into `changedProps`
if (syncInfo) {
Expand All @@ -397,7 +397,7 @@ class DomIfFast extends DomIfBase {
// the next render. Clearing `__invalidProps` here ensures
// `_showHideChildren`'s call to `__syncHostProperties` no-ops, so
// that we don't call `runEffects` more often than necessary.
instance.__syncInfo = null;
this.__syncInfo = null;
this._showHideChildren();
changedProps = Object.assign(syncInfo.changedProps, changedProps);
}
Expand All @@ -406,9 +406,9 @@ class DomIfFast extends DomIfBase {
// Accumulate any values changed while `if` was false, along with the
// runEffects method to sync them, so that we can replay them once `if`
// becomes true
if (instance) {
if (this.__instance) {
if (!syncInfo) {
syncInfo = instance.__syncInfo = { runEffects, changedProps: {} };
syncInfo = this.__syncInfo = { runEffects, changedProps: {} };
}
if (hasPaths) {
// Store root object of any paths; this will ensure direct bindings
Expand Down Expand Up @@ -440,10 +440,9 @@ class DomIfFast extends DomIfBase {
* @return {void}
*/
__syncHostProperties() {
const instance = this.__instance;
const syncInfo = instance && instance.__syncInfo;
const syncInfo = this.__syncInfo;
if (syncInfo) {
instance.__syncInfo = null;
this.__syncInfo = null;
syncInfo.runEffects(syncInfo.changedProps, false);
}
}
Expand All @@ -462,6 +461,7 @@ class DomIfFast extends DomIfBase {
if (this.__instance) {
host._removeBoundDom(this.__instance);
this.__instance = null;
this.__syncInfo = null;
}
}

Expand Down Expand Up @@ -608,11 +608,11 @@ class DomIfLegacy extends DomIfBase {
__syncHostProperties() {
let props = this.__invalidProps;
if (props) {
this.__invalidProps = null;
for (let prop in props) {
this.__instance._setPendingProperty(prop, this.__dataHost[prop]);
}
this.__instance._flushProperties();
this.__invalidProps = null;
}
}

Expand Down

0 comments on commit fe86a8c

Please sign in to comment.