From 6f5da9b16dd7a8d8114d5dccc159274447d73075 Mon Sep 17 00:00:00 2001 From: Martin Trapp <94928215+martrapp@users.noreply.github.com> Date: Fri, 22 Mar 2024 12:08:36 +0100 Subject: [PATCH 1/3] Fix DEV-mode-only style issue of client:only components during view transitions. --- .changeset/spotty-bats-nail.md | 5 +++++ packages/astro/src/transitions/router.ts | 7 +------ 2 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 .changeset/spotty-bats-nail.md diff --git a/.changeset/spotty-bats-nail.md b/.changeset/spotty-bats-nail.md new file mode 100644 index 000000000000..1252031eaebd --- /dev/null +++ b/.changeset/spotty-bats-nail.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Fix DEV-mode-only style issue of client:only components during view transitions. diff --git a/packages/astro/src/transitions/router.ts b/packages/astro/src/transitions/router.ts index db5a5ea731e9..c9dd2497ef45 100644 --- a/packages/astro/src/transitions/router.ts +++ b/packages/astro/src/transitions/router.ts @@ -696,18 +696,13 @@ async function prepareForClientOnlyComponents(newDocument: Document, toLocation: const nextHead = nextPage.contentDocument?.head; if (nextHead) { - // Clear former persist marks - document.head - .querySelectorAll(`style[${PERSIST_ATTR}=""]`) - .forEach((s) => s.removeAttribute(PERSIST_ATTR)); - // Collect the vite ids of all styles present in the next head const viteIds = [...nextHead.querySelectorAll(`style[${VITE_ID}]`)].map((style) => style.getAttribute(VITE_ID) ); // Copy required styles to the new document if they are from hydration. viteIds.forEach((id) => { - const style = document.head.querySelector(`style[${VITE_ID}="${id}"]`); + const style = nextHead.querySelector(`style[${VITE_ID}="${id}"]`); if (style && !newDocument.head.querySelector(`style[${VITE_ID}="${id}"]`)) { newDocument.head.appendChild(style.cloneNode(true)); } From 83c90abb8f60e7c3416afd207fda36dacf948157 Mon Sep 17 00:00:00 2001 From: Martin Trapp <94928215+martrapp@users.noreply.github.com> Date: Fri, 22 Mar 2024 12:16:12 +0100 Subject: [PATCH 2/3] reworded changeset --- .changeset/spotty-bats-nail.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.changeset/spotty-bats-nail.md b/.changeset/spotty-bats-nail.md index 1252031eaebd..8aa5daabb91e 100644 --- a/.changeset/spotty-bats-nail.md +++ b/.changeset/spotty-bats-nail.md @@ -2,4 +2,5 @@ "astro": patch --- -Fix DEV-mode-only style issue of client:only components during view transitions. +Fixes a style issue of "client:only" components in DEV mode during view transitions. + From b1e24036152c629bf268a1273ebbd39b5de3b0af Mon Sep 17 00:00:00 2001 From: Martin Trapp <94928215+martrapp@users.noreply.github.com> Date: Fri, 22 Mar 2024 12:37:13 +0100 Subject: [PATCH 3/3] fixed quotes --- .changeset/spotty-bats-nail.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/spotty-bats-nail.md b/.changeset/spotty-bats-nail.md index 8aa5daabb91e..42a68b5925db 100644 --- a/.changeset/spotty-bats-nail.md +++ b/.changeset/spotty-bats-nail.md @@ -2,5 +2,5 @@ "astro": patch --- -Fixes a style issue of "client:only" components in DEV mode during view transitions. +Fixes a style issue of `client:only` components in DEV mode during view transitions.