-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Yield out potentional slot instructions when rendering dynamic tags (#…
…4981) * Yield out potentional slot instructions when rendering dynamic tags * Adding a changeset * yield instead of return * Handle the fact that renderComponent returns an iterable * Only yield out html once
- Loading branch information
Showing
11 changed files
with
132 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Ensure dynamic tags have their slot instructions yielded |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { expect } from 'chai'; | ||
import * as cheerio from 'cheerio'; | ||
import { loadFixture } from './test-utils.js'; | ||
|
||
describe('Slots with client: directives', () => { | ||
/** @type {import('./test-utils').Fixture} */ | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ root: './fixtures/astro-slot-with-client/' }); | ||
await fixture.build(); | ||
}); | ||
|
||
it('Tags of dynamic tags works', async () => { | ||
const html = await fixture.readFile('/index.html'); | ||
const $ = cheerio.load(html); | ||
expect($('script')).to.have.a.lengthOf(1); | ||
}); | ||
}); |
8 changes: 8 additions & 0 deletions
8
packages/astro/test/fixtures/astro-slot-with-client/astro.config.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { defineConfig } from 'astro/config'; | ||
import preact from '@astrojs/preact'; | ||
|
||
export default defineConfig({ | ||
integrations: [ | ||
preact() | ||
] | ||
}); |
8 changes: 8 additions & 0 deletions
8
packages/astro/test/fixtures/astro-slot-with-client/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "@test/astro-slot-with-client", | ||
"dependencies": { | ||
"astro": "workspace:*", | ||
"@astrojs/preact": "workspace:*", | ||
"preact": "^10.11.0" | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/astro/test/fixtures/astro-slot-with-client/src/components/Slotted.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div id="default"> | ||
<slot /> | ||
</div> |
8 changes: 8 additions & 0 deletions
8
packages/astro/test/fixtures/astro-slot-with-client/src/components/Thing.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
export default function(props) { | ||
return ( | ||
<div class="thing"> | ||
{ props.c } | ||
</div> | ||
) | ||
} |
24 changes: 24 additions & 0 deletions
24
packages/astro/test/fixtures/astro-slot-with-client/src/pages/index.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
import Slotted from '../components/Slotted.astro'; | ||
import Thing from '../components/Thing.jsx'; | ||
const Tag = 'section'; | ||
--- | ||
|
||
<html> | ||
<head> | ||
<!-- Head Stuff --> | ||
</head> | ||
<body> | ||
<Slotted> | ||
<Tag> | ||
<span>More</span> | ||
<Thing client:load> | ||
<div slot="c"> | ||
inner content | ||
</div> | ||
</Thing> | ||
</Tag> | ||
</Slotted> | ||
</body> | ||
</html> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.