summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Arsh <69170106+lilnasy@users.noreply.github.com> 2023-11-29 21:47:48 +0000
committerGravatar GitHub <noreply@github.com> 2023-11-29 15:47:48 -0600
commit3f28336d9a52d7e4364d455ee3128d14d10a078a (patch)
tree8b7d2d0669508e588eb38edd2b0f87e334a8246d
parent8f8a40e93d6a0774ba84a6f5db8c42cd81db005e (diff)
downloadastro-3f28336d9a52d7e4364d455ee3128d14d10a078a.tar.gz
astro-3f28336d9a52d7e4364d455ee3128d14d10a078a.tar.zst
astro-3f28336d9a52d7e4364d455ee3128d14d10a078a.zip
fix(rendering): prevent error when slots is keyed into (#9179)
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
-rw-r--r--.changeset/tall-hotels-argue.md5
-rw-r--r--packages/astro/src/core/render/core.ts2
-rw-r--r--packages/astro/src/runtime/server/render/page.ts2
-rw-r--r--packages/astro/test/astro-slots.test.js9
-rw-r--r--packages/astro/test/fixtures/astro-slots/src/pages/fallback-own.astro10
-rw-r--r--packages/astro/test/fixtures/astro-slots/src/pages/fallback.astro4
6 files changed, 26 insertions, 6 deletions
diff --git a/.changeset/tall-hotels-argue.md b/.changeset/tall-hotels-argue.md
new file mode 100644
index 000000000..aaa5c84dd
--- /dev/null
+++ b/.changeset/tall-hotels-argue.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Fixes an issue where the presence of a slot in a page led to an error.
diff --git a/packages/astro/src/core/render/core.ts b/packages/astro/src/core/render/core.ts
index ed9ea7fdb..25271a94d 100644
--- a/packages/astro/src/core/render/core.ts
+++ b/packages/astro/src/core/render/core.ts
@@ -76,7 +76,7 @@ export async function renderPage({ mod, renderContext, env, cookies }: RenderPag
result,
Component,
renderContext.props,
- null,
+ {},
env.streaming,
renderContext.route
);
diff --git a/packages/astro/src/runtime/server/render/page.ts b/packages/astro/src/runtime/server/render/page.ts
index 8bc5366cf..fbfe567a8 100644
--- a/packages/astro/src/runtime/server/render/page.ts
+++ b/packages/astro/src/runtime/server/render/page.ts
@@ -25,7 +25,7 @@ export async function renderPage(
componentFactory.name,
componentFactory,
pageProps,
- null,
+ {},
true,
route
);
diff --git a/packages/astro/test/astro-slots.test.js b/packages/astro/test/astro-slots.test.js
index 34f1d8225..69a0025e1 100644
--- a/packages/astro/test/astro-slots.test.js
+++ b/packages/astro/test/astro-slots.test.js
@@ -40,13 +40,20 @@ describe('Slots', () => {
expect($('#default').text().trim()).to.equal('Default');
});
- it('Slots render fallback content by default', async () => {
+ it('Slots of a component render fallback content by default', async () => {
const html = await fixture.readFile('/fallback/index.html');
const $ = cheerio.load(html);
expect($('#default')).to.have.lengthOf(1);
});
+ it('Slots of a page render fallback content', async () => {
+ const html = await fixture.readFile('/fallback-own/index.html');
+ const $ = cheerio.load(html);
+
+ expect($('#default')).to.have.lengthOf(1);
+ });
+
it('Slots override fallback content', async () => {
const html = await fixture.readFile('/fallback-override/index.html');
const $ = cheerio.load(html);
diff --git a/packages/astro/test/fixtures/astro-slots/src/pages/fallback-own.astro b/packages/astro/test/fixtures/astro-slots/src/pages/fallback-own.astro
new file mode 100644
index 000000000..89319f8b1
--- /dev/null
+++ b/packages/astro/test/fixtures/astro-slots/src/pages/fallback-own.astro
@@ -0,0 +1,10 @@
+<html>
+ <head>
+ <!-- Head Stuff -->
+ </head>
+ <body>
+ <slot>
+ <div id="default"></div>
+ </slot>
+ </body>
+</html>
diff --git a/packages/astro/test/fixtures/astro-slots/src/pages/fallback.astro b/packages/astro/test/fixtures/astro-slots/src/pages/fallback.astro
index 88aba06e9..aa1a47958 100644
--- a/packages/astro/test/fixtures/astro-slots/src/pages/fallback.astro
+++ b/packages/astro/test/fixtures/astro-slots/src/pages/fallback.astro
@@ -7,8 +7,6 @@ import Fallback from '../components/Fallback.astro';
<!-- Head Stuff -->
</head>
<body>
- <div id="fallback">
- <Fallback />
- </div>
+ <Fallback />
</body>
</html>