* Requests the element to be mounted as soon as possible. * @return {!Promise} * @final
()
| 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 |
no test coverage detected