mirror of
https://github.com/withastro/astro.git
synced 2025-01-06 22:10:10 -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,
|
result,
|
||||||
Component,
|
Component,
|
||||||
renderContext.props,
|
renderContext.props,
|
||||||
null,
|
{},
|
||||||
env.streaming,
|
env.streaming,
|
||||||
renderContext.route
|
renderContext.route
|
||||||
);
|
);
|
||||||
|
|
|
@ -25,7 +25,7 @@ export async function renderPage(
|
||||||
componentFactory.name,
|
componentFactory.name,
|
||||||
componentFactory,
|
componentFactory,
|
||||||
pageProps,
|
pageProps,
|
||||||
null,
|
{},
|
||||||
true,
|
true,
|
||||||
route
|
route
|
||||||
);
|
);
|
||||||
|
|
|
@ -40,13 +40,20 @@ describe('Slots', () => {
|
||||||
expect($('#default').text().trim()).to.equal('Default');
|
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 html = await fixture.readFile('/fallback/index.html');
|
||||||
const $ = cheerio.load(html);
|
const $ = cheerio.load(html);
|
||||||
|
|
||||||
expect($('#default')).to.have.lengthOf(1);
|
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 () => {
|
it('Slots override fallback content', async () => {
|
||||||
const html = await fixture.readFile('/fallback-override/index.html');
|
const html = await fixture.readFile('/fallback-override/index.html');
|
||||||
const $ = cheerio.load(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 Stuff -->
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="fallback">
|
<Fallback />
|
||||||
<Fallback />
|
|
||||||
</div>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue