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:
parent
8f8a40e93d
commit
3f28336d9a
6 changed files with 26 additions and 6 deletions
5
.changeset/tall-hotels-argue.md
Normal file
5
.changeset/tall-hotels-argue.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Fixes an issue where the presence of a slot in a page led to an error.
|
|
@ -76,7 +76,7 @@ export async function renderPage({ mod, renderContext, env, cookies }: RenderPag
|
|||
result,
|
||||
Component,
|
||||
renderContext.props,
|
||||
null,
|
||||
{},
|
||||
env.streaming,
|
||||
renderContext.route
|
||||
);
|
||||
|
|
|
@ -25,7 +25,7 @@ export async function renderPage(
|
|||
componentFactory.name,
|
||||
componentFactory,
|
||||
pageProps,
|
||||
null,
|
||||
{},
|
||||
true,
|
||||
route
|
||||
);
|
||||
|
|
|
@ -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);
|
||||
|
|
10
packages/astro/test/fixtures/astro-slots/src/pages/fallback-own.astro
vendored
Normal file
10
packages/astro/test/fixtures/astro-slots/src/pages/fallback-own.astro
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
<html>
|
||||
<head>
|
||||
<!-- Head Stuff -->
|
||||
</head>
|
||||
<body>
|
||||
<slot>
|
||||
<div id="default"></div>
|
||||
</slot>
|
||||
</body>
|
||||
</html>
|
|
@ -7,8 +7,6 @@ import Fallback from '../components/Fallback.astro';
|
|||
<!-- Head Stuff -->
|
||||
</head>
|
||||
<body>
|
||||
<div id="fallback">
|
||||
<Fallback />
|
||||
</div>
|
||||
<Fallback />
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue