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

Method toggleLoading

src/custom-element.js:2052–2071  ·  view source on GitHub ↗

* Turns the loading indicator on or off. * @param {boolean} state * @param {boolean=} force * @public @final

(state, force = false)

Source from the content-addressed store, hash-verified

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.

Callers 5

setReadyStateInternalMethod · 0.95
connectedCallbackMethod · 0.95
disconnectMethod · 0.95
layoutCallbackMethod · 0.95
renderStartedMethod · 0.95

Calls 4

getAmpDocMethod · 0.95
isLoadingEnabled_Method · 0.95
untrackMethod · 0.80
trackMethod · 0.45

Tested by

no test coverage detected