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

Method mount

src/custom-element.js:696–721  ·  view source on GitHub ↗

* Requests the element to be mounted as soon as possible. * @return {!Promise} * @final

()

Source from the content-addressed store, hash-verified

694 * @final
695 */
696 mount() {
697 if (this.mountPromise_) {
698 return this.mountPromise_;
699 }
700
701 // Create the abort controller right away to ensure that we the unmount
702 // will properly cancel this operation.
703 this.mountAbortController_ =
704 this.mountAbortController_ || new AbortController();
705 const {signal} = this.mountAbortController_;
706
707 const readyPromise = this.signals_.whenSignal(
708 CommonSignals_Enum.READY_TO_UPGRADE
709 );
710 return readyPromise.then(() => {
711 if (!this.R1()) {
712 return this.whenBuilt();
713 }
714 if (signal.aborted) {
715 throw cancellation();
716 }
717 const scheduler = getSchedulerForDoc(this.getAmpDoc());
718 scheduler.scheduleAsap(this);
719 return this.whenMounted();
720 });
721 }
722
723 /**
724 * Unmounts the element and makes it ready for the next mounting

Callers 5

ensureLoadedMethod · 0.95
test-slot.jsFile · 0.45
getImgFunction · 0.45

Calls 9

R1Method · 0.95
whenBuiltMethod · 0.95
getAmpDocMethod · 0.95
whenMountedMethod · 0.95
cancellationFunction · 0.90
getSchedulerForDocFunction · 0.90
whenSignalMethod · 0.80
scheduleAsapMethod · 0.80
thenMethod · 0.45

Tested by

no test coverage detected