Skip to content

Commit 8306ce1

Browse files
authored
Fixes a style issue of client:only components in DEV mode during view transitions. (#10532)
* Fix DEV-mode-only style issue of client:only components during view transitions. * reworded changeset * fixed quotes
1 parent 8cac744 commit 8306ce1

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

.changeset/spotty-bats-nail.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"astro": patch
3+
---
4+
5+
Fixes a style issue of `client:only` components in DEV mode during view transitions.
6+

packages/astro/src/transitions/router.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -696,18 +696,13 @@ async function prepareForClientOnlyComponents(newDocument: Document, toLocation:
696696

697697
const nextHead = nextPage.contentDocument?.head;
698698
if (nextHead) {
699-
// Clear former persist marks
700-
document.head
701-
.querySelectorAll(`style[${PERSIST_ATTR}=""]`)
702-
.forEach((s) => s.removeAttribute(PERSIST_ATTR));
703-
704699
// Collect the vite ids of all styles present in the next head
705700
const viteIds = [...nextHead.querySelectorAll(`style[${VITE_ID}]`)].map((style) =>
706701
style.getAttribute(VITE_ID)
707702
);
708703
// Copy required styles to the new document if they are from hydration.
709704
viteIds.forEach((id) => {
710-
const style = document.head.querySelector(`style[${VITE_ID}="${id}"]`);
705+
const style = nextHead.querySelector(`style[${VITE_ID}="${id}"]`);
711706
if (style && !newDocument.head.querySelector(`style[${VITE_ID}="${id}"]`)) {
712707
newDocument.head.appendChild(style.cloneNode(true));
713708
}

0 commit comments

Comments
 (0)