fix: no deletion of scripts during view transition (#8636)

This commit is contained in:
Martin Trapp 2023-09-22 18:01:22 +02:00 committed by GitHub
parent 0352dec47b
commit 974d5117ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
fix: no deletion of scripts during view transition

View file

@ -219,13 +219,13 @@ const { fallback = 'animate' } = Astro.props as Props;
for (const s2 of newDocument.scripts) { for (const s2 of newDocument.scripts) {
if ( if (
// Inline // Inline
(s1.textContent && s1.textContent === s2.textContent) || (!s1.src && s1.textContent === s2.textContent) ||
// External // External
(s1.type === s2.type && s1.src === s2.src) (s1.src && s1.type === s2.type && s1.src === s2.src)
) { ) {
s2.remove(); // the old script is in the new document: we mark it as executed to prevent re-execution
} else { s2.dataset.astroExec = '';
s1.remove(); break;
} }
} }
} }