diff options
author | 2023-09-22 18:01:22 +0200 | |
---|---|---|
committer | 2023-09-22 12:01:22 -0400 | |
commit | 974d5117abc8b47f8225e455b9285c88e305272f (patch) | |
tree | 40abe6776c826f1cf88ff6c2319cc62447bd542e | |
parent | 0352dec47b955699d91efa5d499420ca56f67e80 (diff) | |
download | astro-974d5117abc8b47f8225e455b9285c88e305272f.tar.gz astro-974d5117abc8b47f8225e455b9285c88e305272f.tar.zst astro-974d5117abc8b47f8225e455b9285c88e305272f.zip |
fix: no deletion of scripts during view transition (#8636)
-rw-r--r-- | .changeset/short-cougars-worry.md | 5 | ||||
-rw-r--r-- | packages/astro/components/ViewTransitions.astro | 10 |
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; } } } |