summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/short-cougars-worry.md5
-rw-r--r--packages/astro/components/ViewTransitions.astro10
2 files changed, 10 insertions, 5 deletions
diff --git a/.changeset/short-cougars-worry.md b/.changeset/short-cougars-worry.md
new file mode 100644
index 000000000..05c1c20b5
--- /dev/null
+++ b/.changeset/short-cougars-worry.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+fix: no deletion of scripts during view transition
diff --git a/packages/astro/components/ViewTransitions.astro b/packages/astro/components/ViewTransitions.astro
index aa266af13..230b2f302 100644
--- a/packages/astro/components/ViewTransitions.astro
+++ b/packages/astro/components/ViewTransitions.astro
@@ -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;
}
}
}