mirror of
https://github.com/withastro/astro.git
synced 2025-01-20 22:12:38 -05:00
Don't try to load partytown scripts in the main thread during view transitions (#9658)
This commit is contained in:
parent
e72efd6a9a
commit
a3b5695176
2 changed files with 8 additions and 1 deletions
5
.changeset/early-taxis-love.md
Normal file
5
.changeset/early-taxis-love.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"astro": patch
|
||||
---
|
||||
|
||||
Fixes an issue caused by trying to load text/partytown scripts during view transitions
|
|
@ -151,12 +151,14 @@ function runScripts() {
|
|||
let wait = Promise.resolve();
|
||||
for (const script of Array.from(document.scripts)) {
|
||||
if (script.dataset.astroExec === '') continue;
|
||||
const type = script.getAttribute('type');
|
||||
if (type && type !== 'module' && type !== 'text/javascript') continue;
|
||||
const newScript = document.createElement('script');
|
||||
newScript.innerHTML = script.innerHTML;
|
||||
for (const attr of script.attributes) {
|
||||
if (attr.name === 'src') {
|
||||
const p = new Promise((r) => {
|
||||
newScript.onload = r;
|
||||
newScript.onload = newScript.onerror = r;
|
||||
});
|
||||
wait = wait.then(() => p as any);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue