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:
parent
ab0580bc94
commit
28dd3ce522
2 changed files with 8 additions and 2 deletions
5
.changeset/olive-garlics-marry.md
Normal file
5
.changeset/olive-garlics-marry.md
Normal 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.
|
|
@ -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>`);
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue