0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

fix: server island hydration (#12444)

This commit is contained in:
Emanuele Stoppa 2024-11-20 15:08:26 +00:00 committed by GitHub
parent ab0580bc94
commit 28dd3ce522
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fixes an issue where a server island hydration script might fail case the island ID misses from the DOM.

View file

@ -81,8 +81,8 @@ let response = await fetch('${serverIslandUrl}', {
method: 'POST',
body: JSON.stringify(data),
});
if(response.status === 200 && response.headers.get('content-type') === 'text/html') {
if (script) {
if(response.status === 200 && response.headers.get('content-type') === 'text/html') {
let html = await response.text();
// Swap!
@ -97,6 +97,7 @@ if(response.status === 200 && response.headers.get('content-type') === 'text/htm
script.before(frag);
}
script.remove();
}
</script>`);
},
};