Skip to content

Commit

Permalink
Fix DEV mode on Safari when view transitioning to client:only compone…
Browse files Browse the repository at this point in the history
…nts (#9000)

* Fix DEV mode on Safari when view transitioning to client:only components

* Update .changeset/eighty-ladybugs-shake.md

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>

---------

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
  • Loading branch information
martrapp and sarah11918 authored Nov 6, 2023
1 parent 4983ace commit 35739d0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/eighty-ladybugs-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes an error in dev mode on Safari where view transitions prevented navigating to pages with `client:only` components
5 changes: 2 additions & 3 deletions packages/astro/src/transitions/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,9 +529,8 @@ async function prepareForClientOnlyComponents(newDocument: Document, toLocation:
if (newDocument.body.querySelector(`astro-island[client='only']`)) {
// Load the next page with an empty module loader cache
const nextPage = document.createElement('iframe');
// do not fetch the file from the server, but use the current newDocument
nextPage.srcdoc =
(newDocument.doctype ? '<!DOCTYPE html>' : '') + newDocument.documentElement.outerHTML;
// with srcdoc resolving imports does not work on webkit browsers
nextPage.src = toLocation.href;
nextPage.style.display = 'none';
document.body.append(nextPage);
// silence the iframe's console
Expand Down

0 comments on commit 35739d0

Please sign in to comment.