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

fix(rendering): prevent error when slots is keyed into (#9179)

Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
This commit is contained in:
Arsh 2023-11-29 21:47:48 +00:00 committed by GitHub
parent 8f8a40e93d
commit 3f28336d9a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 26 additions and 6 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fixes an issue where the presence of a slot in a page led to an error.

View file

@ -76,7 +76,7 @@ export async function renderPage({ mod, renderContext, env, cookies }: RenderPag
result,
Component,
renderContext.props,
null,
{},
env.streaming,
renderContext.route
);

View file

@ -25,7 +25,7 @@ export async function renderPage(
componentFactory.name,
componentFactory,
pageProps,
null,
{},
true,
route
);

View file

@ -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);

View file

@ -0,0 +1,10 @@
<html>
<head>
<!-- Head Stuff -->
</head>
<body>
<slot>
<div id="default"></div>
</slot>
</body>
</html>

View file

@ -7,8 +7,6 @@ import Fallback from '../components/Fallback.astro';
<!-- Head Stuff -->
</head>
<body>
<div id="fallback">
<Fallback />
</div>
<Fallback />
</body>
</html>