From 35739d01e9cc4fa31a8b85201feecf29c747eca9 Mon Sep 17 00:00:00 2001 From: Martin Trapp <94928215+martrapp@users.noreply.github.com> Date: Mon, 6 Nov 2023 18:48:34 +0100 Subject: [PATCH] Fix DEV mode on Safari when view transitioning to client:only components (#9000) * Fix DEV mode on Safari when view transitioning to client:only components * Update .changeset/eighty-ladybugs-shake.md Co-authored-by: Sarah Rainsberger --------- Co-authored-by: Sarah Rainsberger --- .changeset/eighty-ladybugs-shake.md | 5 +++++ packages/astro/src/transitions/router.ts | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 .changeset/eighty-ladybugs-shake.md diff --git a/.changeset/eighty-ladybugs-shake.md b/.changeset/eighty-ladybugs-shake.md new file mode 100644 index 000000000000..e34d66c971d4 --- /dev/null +++ b/.changeset/eighty-ladybugs-shake.md @@ -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 diff --git a/packages/astro/src/transitions/router.ts b/packages/astro/src/transitions/router.ts index af8a09d97643..da5496f81ff9 100644 --- a/packages/astro/src/transitions/router.ts +++ b/packages/astro/src/transitions/router.ts @@ -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 ? '' : '') + 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