Skip to content

Commit

Permalink
fix: no deletion of scripts during view transition (#8636)
Browse files Browse the repository at this point in the history
  • Loading branch information
martrapp authored Sep 22, 2023
1 parent 0352dec commit 974d511
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/short-cougars-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

fix: no deletion of scripts during view transition
10 changes: 5 additions & 5 deletions packages/astro/components/ViewTransitions.astro
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,13 @@ const { fallback = 'animate' } = Astro.props as Props;
for (const s2 of newDocument.scripts) {
if (
// Inline
(s1.textContent && s1.textContent === s2.textContent) ||
(!s1.src && s1.textContent === s2.textContent) ||
// External
(s1.type === s2.type && s1.src === s2.src)
(s1.src && s1.type === s2.type && s1.src === s2.src)
) {
s2.remove();
} else {
s1.remove();
// the old script is in the new document: we mark it as executed to prevent re-execution
s2.dataset.astroExec = '';
break;
}
}
}
Expand Down

0 comments on commit 974d511

Please sign in to comment.