summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Ben Holmes <hey@bholmes.dev> 2022-07-08 19:04:27 -0400
committerGravatar GitHub <noreply@github.com> 2022-07-08 19:04:27 -0400
commit957fb50541e15d3876a87f91cd52f29e10a92cc9 (patch)
tree3df86fcbdfc6ddf2aaf9276a0e9804ae82e48b47
parentf9ed77bb0d71d1644d524547a24963210f4ecaff (diff)
downloadastro-957fb50541e15d3876a87f91cd52f29e10a92cc9.tar.gz
astro-957fb50541e15d3876a87f91cd52f29e10a92cc9.tar.zst
astro-957fb50541e15d3876a87f91cd52f29e10a92cc9.zip
chore: changeset (#3873)
-rw-r--r--.changeset/quiet-pugs-tie.md5
-rw-r--r--packages/astro/src/runtime/server/astro-island.ts2
-rw-r--r--packages/astro/src/runtime/server/index.ts4
3 files changed, 10 insertions, 1 deletions
diff --git a/.changeset/quiet-pugs-tie.md b/.changeset/quiet-pugs-tie.md
new file mode 100644
index 000000000..5bad03e91
--- /dev/null
+++ b/.changeset/quiet-pugs-tie.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Fix hydration for SSR components that return null
diff --git a/packages/astro/src/runtime/server/astro-island.ts b/packages/astro/src/runtime/server/astro-island.ts
index 4f7432631..d3a22a5c2 100644
--- a/packages/astro/src/runtime/server/astro-island.ts
+++ b/packages/astro/src/runtime/server/astro-island.ts
@@ -42,7 +42,7 @@ declare const Astro: {
public hydrator: any;
static observedAttributes = ['props'];
connectedCallback() {
- if (this.getAttribute('client') === 'only' || this.firstChild) {
+ if (!this.getAttribute('await-children') || this.firstChild) {
this.childrenConnectedCallback();
} else {
// connectedCallback may run *before* children are rendered (ex. HTML streaming)
diff --git a/packages/astro/src/runtime/server/index.ts b/packages/astro/src/runtime/server/index.ts
index 230c043ed..8188e7165 100644
--- a/packages/astro/src/runtime/server/index.ts
+++ b/packages/astro/src/runtime/server/index.ts
@@ -452,6 +452,10 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr
island.children = `${html ?? ''}${template}`;
+ if (island.children) {
+ island.props['await-children'] = ''
+ }
+
// Scripts to prepend
let prescriptType: PrescriptType = needsHydrationScript
? 'both'