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

Function failedToLoad

src/utils/event-helper.js:222–238  ·  view source on GitHub ↗

* Emit error on load failure. * @param {!Element|!Window} eleOrWindow Supports both Elements and as a special * case Windows.

(eleOrWindow)

Source from the content-addressed store, hash-verified

220 * case Windows.
221 */
222function failedToLoad(eleOrWindow) {
223 // Mark the element as errored since some elements - like HTMLMediaElement
224 // using HTMLSourceElement - do not provide any synchronous way to verify if
225 // they already errored, even though the error event was already dispatched.
226 if (isHTMLMediaElement(eleOrWindow)) {
227 eleOrWindow[MEDIA_LOAD_FAILURE_SRC_PROPERTY] =
228 eleOrWindow.currentSrc || true;
229 }
230
231 // Report failed loads as user errors so that they automatically go
232 // into the "document error" bucket.
233 let target = eleOrWindow;
234 if (target && target.src) {
235 target = target.src;
236 }
237 throw user().createError(LOAD_FAILURE_PREFIX, target);
238}
239
240/**
241 * Returns true if the parameter is a HTMLMediaElement.

Callers 1

loadPromiseFunction · 0.85

Calls 3

userFunction · 0.90
isHTMLMediaElementFunction · 0.85
createErrorMethod · 0.45

Tested by

no test coverage detected