diff --git a/src/base-element.js b/src/base-element.js index e2a5f05e5ded..0bad4fcf25bd 100644 --- a/src/base-element.js +++ b/src/base-element.js @@ -540,13 +540,8 @@ export class BaseElement { /** * Unload heavy elements, remove global listeners, etc. - * - * @return {boolean} Return `true` if the element should be remounted - * the next time it's displayed. */ - unmountCallback() { - return false; - } + unmountCallback() {} /** * Subclasses can override this method to opt-in into receiving additional diff --git a/src/custom-element.js b/src/custom-element.js index 09b3ac2445f1..faf2c3acc0e9 100644 --- a/src/custom-element.js +++ b/src/custom-element.js @@ -714,12 +714,9 @@ function createBaseCustomElementClass(win, elementConnectedCallback) { const scheduler = getSchedulerForDoc(this.getAmpDoc()); scheduler.unschedule(this); - // Try to unmount. Not every element has been mounted, can be unmounted - // or has anything to unmount. - const reMount = - !this.mountPromise_ || !this.impl_ || this.impl_.unmountCallback(); - if (!reMount) { - return; + // Try to unmount if the element has been built already. + if (this.isBuilt()) { + this.impl_.unmountCallback(); } // Complete unmount and reset the state. diff --git a/testing/element-v1.js b/testing/element-v1.js index 7f3bcedc9f9e..7ddbf7f558cc 100644 --- a/testing/element-v1.js +++ b/testing/element-v1.js @@ -70,6 +70,15 @@ const RULES = [ return !hasCallback; }, }, + { + name: 'Must not have resumeCallback', + test: (implClass) => { + const hasCallback = + implClass.prototype.resumeCallback !== + BaseElement.prototype.resumeCallback; + return !hasCallback; + }, + }, { name: 'If load==true, must also have ensureLoaded',