diff --git a/lib/elements/dom-if.js b/lib/elements/dom-if.js index 103e4e2691..729833a32c 100644 --- a/lib/elements/dom-if.js +++ b/lib/elements/dom-if.js @@ -339,6 +339,7 @@ class DomIfFast extends DomIfBase { constructor() { super(); this.__instance = null; + this.__syncInfo = null; } /** @@ -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) { @@ -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); } @@ -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 @@ -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); } } @@ -462,6 +461,7 @@ class DomIfFast extends DomIfBase { if (this.__instance) { host._removeBoundDom(this.__instance); this.__instance = null; + this.__syncInfo = null; } } @@ -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; } }