summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/olive-gifts-hope.md5
-rw-r--r--packages/astro/src/runtime/server/astro-island.ts11
2 files changed, 13 insertions, 3 deletions
diff --git a/.changeset/olive-gifts-hope.md b/.changeset/olive-gifts-hope.md
new file mode 100644
index 000000000..32a01c519
--- /dev/null
+++ b/.changeset/olive-gifts-hope.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Remove optional chaining in astro-island
diff --git a/packages/astro/src/runtime/server/astro-island.ts b/packages/astro/src/runtime/server/astro-island.ts
index 2e16a547a..706ccdd88 100644
--- a/packages/astro/src/runtime/server/astro-island.ts
+++ b/packages/astro/src/runtime/server/astro-island.ts
@@ -90,7 +90,10 @@ declare const Astro: {
);
}
hydrate = () => {
- if (!this.hydrator || this.parentElement?.closest('astro-island[ssr]')) {
+ if (
+ !this.hydrator ||
+ (this.parentElement && this.parentElement.closest('astro-island[ssr]'))
+ ) {
return;
}
const slotted = this.querySelectorAll('astro-slot');
@@ -99,12 +102,14 @@ declare const Astro: {
// This happens if slots were passed but the client component did not render them.
const templates = this.querySelectorAll('template[data-astro-template]');
for (const template of templates) {
- if (!template.closest(this.tagName)?.isSameNode(this)) continue;
+ const closest = template.closest(this.tagName);
+ if (!closest || !closest.isSameNode(this)) continue;
slots[template.getAttribute('data-astro-template') || 'default'] = template.innerHTML;
template.remove();
}
for (const slot of slotted) {
- if (!slot.closest(this.tagName)?.isSameNode(this)) continue;
+ const closest = slot.closest(this.tagName);
+ if (!closest || !closest.isSameNode(this)) continue;
slots[slot.getAttribute('name') || 'default'] = slot.innerHTML;
}
const props = this.hasAttribute('props')