PageSourceSearch

https://fremtenkt.no/assets/helpers/media_reload-2ee952bc7154bc6c5…bd3954e460e7ffafed0172d938b785ce1a073e70.js

js fremtenkt.no collected 2026-10-07 00:43:56 UTC 1,204 bytes, 22 lines download raw bytes

1// Restarts media that a Turbo visit brought onto the page dead.
2//
3// Turbo parses each visit's HTML with DOMParser, and that document has no browsing context.
4// Chromium starts loading a <video>/<audio> the moment it lands in a document, so the load
5// runs there and fails ("Media load rejected by URL safety check"), leaving the element in
6// NETWORK_NO_SOURCE. Turbo then swaps the element into the live page, but a media element
7// only starts loading on insertion while its network state is still NETWORK_EMPTY — so it
8// stays dead until something calls load(). Full page loads never hit this.
9//
10// Shared between the body-level sweep (light DOM) and the Pulse shadow roots, which
11// light-DOM queries don't reach.
12export function reloadStrandedMedia(root) {
13  root.querySelectorAll("video, audio").forEach((media) => {
14    if (neverStartedLoading(media)) media.load()
15  })
16}
17
18// Media that genuinely failed — a 404, an unplayable codec — also ends in NETWORK_NO_SOURCE,
19// but with a currentSrc, and reloading that would only repeat a request we know fails.
20function neverStartedLoading(media) {
21  return media.networkState === HTMLMediaElement.NETWORK_NO_SOURCE && !media.currentSrc
22};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.