* Turns the loading indicator on or off. * @param {boolean} state * @param {boolean=} force * @public @final
(state, force = false)
| 2050 | * @public @final |
| 2051 | */ |
| 2052 | toggleLoading(state, force = false) { |
| 2053 | // TODO(dvoytenko, #9177): cleanup `this.ownerDocument.defaultView` |
| 2054 | // once investigation is complete. It appears that we get a lot of |
| 2055 | // errors here once the iframe is destroyed due to timer. |
| 2056 | if (!this.ownerDocument || !this.ownerDocument.defaultView) { |
| 2057 | return; |
| 2058 | } |
| 2059 | |
| 2060 | const loadingIndicator = Services.loadingIndicatorOrNull( |
| 2061 | this.getAmpDoc() |
| 2062 | ); |
| 2063 | if (loadingIndicator) { |
| 2064 | state = state && this.isLoadingEnabled_(force); |
| 2065 | if (state) { |
| 2066 | loadingIndicator.track(this); |
| 2067 | } else { |
| 2068 | loadingIndicator.untrack(this); |
| 2069 | } |
| 2070 | } |
| 2071 | } |
| 2072 | |
| 2073 | /** |
| 2074 | * Returns an optional overflow element for this custom element. |
no test coverage detected