MCPcopy
hub / github.com/ampproject/amphtml / unmount

Method unmount

src/custom-element.js:728–764  ·  view source on GitHub ↗

* Unmounts the element and makes it ready for the next mounting * operation. * @final

()

Source from the content-addressed store, hash-verified

726 * @final
727 */
728 unmount() {
729 // Ensure that the element is paused.
730 if (this.isConnected_) {
731 this.pause();
732 }
733
734 // Legacy R0 elements simply unlayout.
735 if (!this.R1()) {
736 this.unlayout_();
737 return;
738 }
739
740 // Cancel the currently mounting operation.
741 if (this.mountAbortController_) {
742 this.mountAbortController_.abort();
743 this.mountAbortController_ = null;
744 }
745
746 // Unschedule a currently pending mount request.
747 const scheduler = getSchedulerForDoc(this.getAmpDoc());
748 scheduler.unschedule(this);
749
750 // Try to unmount if the element has been built already.
751 if (this.mounted_) {
752 this.impl_.unmountCallback();
753 }
754
755 // Complete unmount and reset the state.
756 this.mounted_ = false;
757 this.mountPromise_ = null;
758 this.reset_();
759
760 // Prepare for the next mount if the element is connected.
761 if (this.isConnected_) {
762 this.upgradeOrSchedule_(/* opt_disablePreload */ true);
763 }
764 }
765
766 /**
767 * Returns the promise that's resolved when the element has been mounted. If

Callers 15

disconnectMethod · 0.95
test-slot.jsFile · 0.80
test-amp-img-v1.jsFile · 0.80
unmountFunction · 0.80
unloadMethod · 0.80
test-component.jsFile · 0.80
test-component.jsFile · 0.80
test-component.jsFile · 0.80

Calls 10

pauseMethod · 0.95
R1Method · 0.95
unlayout_Method · 0.95
getAmpDocMethod · 0.95
reset_Method · 0.95
upgradeOrSchedule_Method · 0.95
getSchedulerForDocFunction · 0.90
unscheduleMethod · 0.80
abortMethod · 0.45
unmountCallbackMethod · 0.45

Tested by

no test coverage detected