Repository navigation
Fix video and audio elements broken after view transition navigation - #17603
Merged
Merged
Conversation
…back (#17601) DOMParser.parseFromString() creates <video> and <audio> elements in an inert document where the browser never initialises the media stack. When these elements are moved into the live DOM via swapBodyElement(), they retain their inert state — controls stay disabled and playback fails. Add reifyMediaElements() to replace each media element with a fresh copy created via document.createElement() in the live document, forcing proper browser initialisation. Runs alongside the existing attachShadowRoots() post-swap fixup.
1 task
🦋 Changeset detectedLatest commit: 3c715f2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 417 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
@martrapp does this sound right to you? I didn't know about this need, however I've only tested |
Member
|
Ah, I got Rickrolled by the minimal reproduction in #17601! |
martrapp
approved these changes
Aug 6, 2026
martrapp
left a comment
Member
There was a problem hiding this comment.
I wasn't aware of this limitation either, but looking at the minimal reproduction and digging more into DOMParser behaviour, this makes a lot of sense. Thank you @alexschcom for pointing out.
Looks good to me!
Merged
thelazylamaGit
pushed a commit
to thelazylamaGit/astro
that referenced
this pull request
Aug 7, 2026
…back (withastro#17601) (withastro#17603) DOMParser.parseFromString() creates <video> and <audio> elements in an inert document where the browser never initialises the media stack. When these elements are moved into the live DOM via swapBodyElement(), they retain their inert state — controls stay disabled and playback fails. Add reifyMediaElements() to replace each media element with a fresh copy created via document.createElement() in the live document, forcing proper browser initialisation. Runs alongside the existing attachShadowRoots() post-swap fixup. Co-authored-by: Matthew Phillips <[email protected]>
pull Bot
pushed a commit
to Penguinjanator/ComfyUI_frontend
that referenced
this pull request
Aug 11, 2026
…omfy.org (Comfy-Org#15010) ## Summary A recent Chrome update broke every `<video>`/`<audio>` on comfy.org when the page is reached via Astro `<ClientRouter />` soft navigation (e.g. /learning → a tutorial watch page): the router parses the incoming page with DOMParser into an inert document where the media stack is never initialised, so swapped-in media reports `MEDIA_ERR_SRC_NOT_SUPPORTED` ("no supported sources") despite a valid `src`. Hard refresh works; any client-side navigation does not. ## Changes - **What**: Add `reifyMediaElements()` (mirrors unreleased upstream fix withastro/astro#17603) that replaces swapped-in media elements with fresh `document.createElement()` copies, run on `astro:after-swap` in `BaseLayout.astro` — synchronously before Vue island hydration, so `VideoPlayer.vue` hydrates onto the live elements. Also copies the `muted` property across (`setAttribute('muted')` only sets `defaultMuted`), without which muted autoplay loops stay blocked; upstream's fix has this gap. Unit tests cover attribute/child/muted copying and element position. - **Removal path**: Delete once Astro ships a release containing withastro/astro#17603 (not in 7.2.0; no 6.x backport). ## Review Focus - Timing: `astro:after-swap` fires synchronously after the swap, before island hydration microtasks run, so Vue never binds to the stale elements. Verified in Chromium: watch-page autoplay + custom controls, and home-page scroll-triggered loops all behave identically to a hard load after soft navigation.
r4lphio
added a commit
to ucountcampaign/ucount-website
that referenced
this pull request
Aug 12, 2026
## What this does In Firefox, navigating between pages left product photos and team portraits blank until a manual reload. Astro's ClientRouter builds the next page in a detached document and adopts it into the live one, and Firefox never starts the image downloads for those adopted elements - the network panel shows them dying as NS_BINDING_ABORTED. A small script now re-creates any not-yet-loaded image right after each page swap, so the browser fetches it normally. This is the same approach Astro itself shipped for video and audio elements (withastro/astro#17603), which do not cover images. ## Verification - pnpm build passes. - In a Chromium browser session against the dev server: navigated Home to About via the client router - 6 of 6 Wix portraits loaded, none broken; then About to Shop - 60 of 60 images loaded, none broken. The guard leaves already-loaded images untouched, so healthy browsers see no change. - The failure itself is Firefox-only and could not be reproduced in Chromium; please confirm on the branch preview URL in Firefox by navigating between pages without reloading. ## Intentional decisions - The swap fires before the new page paints, so replacing images at that moment causes no visible flicker. - Images that are already complete with real dimensions are skipped to avoid restarting healthy loads. - Fixing at the layout level (one listener) rather than per-page keeps every current and future page covered. 🤖 Generated with [Claude Code](https://claude.com/claude-code) using Claude Fable 5.
dadezzz
pushed a commit
to dadezzz/university_notes
that referenced
this pull request
Aug 16, 2026
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [astro](https://astro.build) ([source](https://github.com/withastro/astro/tree/HEAD/packages/astro)) | [`7.2.0` → `7.2.1`](https://renovatebot.com/diffs/npm/astro/7.2.0/7.2.1) |  |  | --- ### Release Notes <details> <summary>withastro/astro (astro)</summary> ### [`v7.2.1`](https://github.com/withastro/astro/blob/HEAD/packages/astro/CHANGELOG.md#721) [Compare Source](https://github.com/withastro/astro/compare/[email protected]@7.2.1) ##### Patch Changes - [#​17612](withastro/astro#17612) [`7133730`](withastro/astro@7133730) Thanks [@​thelazylamaGit](https://github.com/thelazylamaGit)! - Fixes CSS hot module replacement after navigating between pages with `ClientRouter` - [#​17628](withastro/astro#17628) [`4ada248`](withastro/astro@4ada248) Thanks [@​astrobot-houston](https://github.com/astrobot-houston)! - Fixes a CSP violation when using both `security.csp` and `experimental.clientPrerender` with `data-astro-prefetch` links. The dynamically injected `<script type="speculationrules">` now uses a static `"source": "document"` approach with a CSS selector, producing a deterministic payload that is hashed and included in the CSP `script-src` directive at build time. - [#​17605](withastro/astro#17605) [`89e4647`](withastro/astro@89e4647) Thanks [@​ashleigh-yeoman](https://github.com/ashleigh-yeoman)! - Fixes middleware HMR not responding to changes in imported modules. Previously, only direct edits to the middleware file would trigger a reload. - [#​17582](withastro/astro#17582) [`bd2c1a5`](withastro/astro@bd2c1a5) Thanks [@​astrobot-houston](https://github.com/astrobot-houston)! - Fixes a regression where content collection `reference()` fields silently accepted entry IDs that don't exist, such as an ID that doesn't match a loader's slugified version of it. Astro now logs an error for references that point to a missing entry after all loaders finish syncing. - [#​17661](withastro/astro#17661) [`97b0cc7`](withastro/astro@97b0cc7) Thanks [@​ArmandPhilippot](https://github.com/ArmandPhilippot)! - Improves Markdown options documentation with links to the Markdown guide and official processors. - [#​17349](withastro/astro#17349) [`4328c73`](withastro/astro@4328c73) Thanks [@​astrobot-houston](https://github.com/astrobot-houston)! - Fixes an issue where requests handled by the dev prerender environment (e.g. `/_image` with `@astrojs/cloudflare`'s `prerenderEnvironment: 'node'`) returned a 500 when a prerendered catch-all route existed, because non-prerendered route modules were imported in an environment where their runtime-specific APIs are unavailable - [#​17603](withastro/astro#17603) [`722eed6`](withastro/astro@722eed6) Thanks [@​astrobot-houston](https://github.com/astrobot-houston)! - Fixes `<video>` and `<audio>` elements being non-functional after navigating via view transitions (`<ClientRouter />`) - [#​17616](withastro/astro#17616) [`3a890d2`](withastro/astro@3a890d2) Thanks [@​lazerg](https://github.com/lazerg)! - Fixes `experimental.incrementalBuild` re-rendering unchanged routes that import more than one asset. The route's dependency hash depended on the order the assets finished building, so two builds of identical sources could produce different hashes. The hash is now based on the file name each asset resolves to. - [#​17547](withastro/astro#17547) [`fba468c`](withastro/astro@fba468c) Thanks [@​dmgawel](https://github.com/dmgawel)! - Improves `getCollection()` and `getEntry()` performance for entries without local image references - [#​17602](withastro/astro#17602) [`16e0d9d`](withastro/astro@16e0d9d) Thanks [@​astrobot-houston](https://github.com/astrobot-houston)! - Fixes a build error caused by hash collisions in generated content collection image import identifiers </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xNy4xIiwidXBkYXRlZEluVmVyIjoiNDQuMTcuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->
martrapp
added a commit
that referenced
this pull request
Aug 20, 2026
…17750) * fix(transitions): do not re-create media inside persisted subtrees reifyMediaElements() (#17603) runs after transition:persist elements from the old document have been moved into the new body, so it also replaced the live <audio>/<video> nodes carried over from the previous page. Those nodes were never parsed by DOMParser and are not inert; re-creating them resets currentTime/paused and drops listeners and framework refs, which breaks persistent players on every navigation. Skip media whose nearest [data-astro-transition-persist] host is one of the persisted elements. Media inside a persist container that appears for the first time on the new page still get reified, so #17601 stays fixed for that case. * fix(transitions): skip exactly the media that were live before the swap Collect the <video>/<audio> nodes of the old body before the swap and skip those in reifyMediaElements(). This is precise by construction: a node that was live and is still in the new body got there through transition:persist — at any nesting depth, including persist containers nested inside a persisted one that have no counterpart on the new page, and the attribute placed on the media element itself. Media parsed from the new document are never in the set and still get reified (#17601 stays fixed). * test(e2e): persisted media keep DOM identity across ClientRouter navigation Two view-transitions e2e tests that fail on main and pass with the fix: an expando set on the persisted <video> before navigation must still be there afterwards — for transition:persist on the media element itself, and for media inside an inner persist container that has no counterpart on the next page (it travels with its matched outer container). The existing '<video> can persist' test only asserts that currentTime grows, which a freshly re-created autoplaying element also satisfies — that is why the regression went unnoticed. Also spells out in swap-functions.ts why the liveMedia snapshot is sufficient. * chore: re-sync pull request head * more user-centric, less technical ;-) * Update persisted-media-keep-identity.md --------- Co-authored-by: Martin Trapp <[email protected]>
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
<video>and<audio>elements are now fully functional after navigating to a page via<ClientRouter />. Previously, media controls were permanently disabled and playback was impossible after any client-side navigation.DOMParser.parseFromString(), which parses incoming page HTML into an inert document where the browser never initializes the media stack. Moving those elements into the live DOM does not retroactively initialize it. The fix adds areifyMediaElements()post-swap step (following the existingattachShadowRoots()pattern) that replaces each<video>/<audio>element with a fresh copy created viadocument.createElement(), forcing the browser to properly initialize the media stack.Testing
Docs
Closes #17601