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

Method isLoadingEnabled_

src/custom-element.js:2018–2044  ·  view source on GitHub ↗

* Whether the loading can be shown for this element. * @param {boolean} force * @return {boolean} * @private

(force)

Source from the content-addressed store, hash-verified

2016 * @private
2017 */
2018 isLoadingEnabled_(force) {
2019 // No loading indicator will be shown if either one of these conditions
2020 // true:
2021 // 1. The document is A4A.
2022 // 2. `noloading` attribute is specified;
2023 // 3. The element has already been laid out, and does not support reshowing the indicator (include having loading
2024 // error);
2025 // 4. The element is too small or has not yet been measured;
2026 // 5. The element has not been allowlisted;
2027 // 6. The element is an internal node (e.g. `placeholder` or `fallback`);
2028 // 7. The element's layout is not nodisplay.
2029
2030 const laidOut =
2031 this.layoutCount_ > 0 ||
2032 this.signals_.get(CommonSignals_Enum.RENDER_START);
2033 if (
2034 this.layout_ == Layout_Enum.NODISPLAY ||
2035 this.hasAttribute('noloading') ||
2036 (laidOut && !force) ||
2037 !isLoadingAllowed(this) ||
2038 query.isInternalOrServiceNode(this)
2039 ) {
2040 return false;
2041 }
2042
2043 return true;
2044 }
2045
2046 /**
2047 * Turns the loading indicator on or off.

Callers 2

toggleLoadingMethod · 0.95

Calls 2

isLoadingAllowedFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected