mirror of
https://github.com/withastro/astro.git
synced 2025-01-27 22:19:04 -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();
|
let wait = Promise.resolve();
|
||||||
for (const script of Array.from(document.scripts)) {
|
for (const script of Array.from(document.scripts)) {
|
||||||
if (script.dataset.astroExec === '') continue;
|
if (script.dataset.astroExec === '') continue;
|
||||||
|
const type = script.getAttribute('type');
|
||||||
|
if (type && type !== 'module' && type !== 'text/javascript') continue;
|
||||||
const newScript = document.createElement('script');
|
const newScript = document.createElement('script');
|
||||||
newScript.innerHTML = script.innerHTML;
|
newScript.innerHTML = script.innerHTML;
|
||||||
for (const attr of script.attributes) {
|
for (const attr of script.attributes) {
|
||||||
if (attr.name === 'src') {
|
if (attr.name === 'src') {
|
||||||
const p = new Promise((r) => {
|
const p = new Promise((r) => {
|
||||||
newScript.onload = r;
|
newScript.onload = newScript.onerror = r;
|
||||||
});
|
});
|
||||||
wait = wait.then(() => p as any);
|
wait = wait.then(() => p as any);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue