forked from laptou/astro
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix slot attribute inside expressions (withastro#3837)
* fix: use slots inside expressions * test: add test for conditional named slots * test: fix incorrect test fixture * chore: update `@astrojs/compiler` * chore: add test coverage for `switch` Co-authored-by: Nate Moore <nate@astro.build>
- Loading branch information
1 parent
c191098
commit 5afb807
Showing
8 changed files
with
89 additions
and
5 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 | ||
--- | ||
|
||
Fix usage of slots inside expressions |
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
20 changes: 20 additions & 0 deletions
20
packages/astro/test/fixtures/astro-expr/src/pages/switch.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,20 @@ | ||
--- | ||
let title = 'Switch'; | ||
let colors = ['red', 'yellow', 'blue']; | ||
--- | ||
|
||
<html> | ||
<head> | ||
<title>{title}</title> | ||
</head> | ||
<body> | ||
{() => { | ||
const color = colors[1]; | ||
switch (color) { | ||
case 'red': return <div id="red">red</div>; | ||
case 'yellow': return <div id="yellow">yellow</div> | ||
case 'blue': return <div id="blue">blue</div> | ||
} | ||
}} | ||
</body> | ||
</html> |
27 changes: 27 additions & 0 deletions
27
packages/astro/test/fixtures/astro-slots/src/pages/conditional.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,27 @@ | ||
--- | ||
import Slotted from '../components/Slotted.astro'; | ||
--- | ||
|
||
<html> | ||
<head> | ||
<!-- Head Stuff --> | ||
</head> | ||
<body> | ||
<Slotted> | ||
{true && <span slot="a">A</span>} | ||
{true ? <span slot="b">B</span> : null} | ||
{() => <span slot="c">C</span>} | ||
{() => { | ||
const value = 0.33; | ||
if (value > 0.25) { | ||
return <span>Default</span> | ||
} else if (value > 0.5) { | ||
return <span>Another</span> | ||
} else if (value > 0.75) { | ||
return <span>Other</span> | ||
} | ||
return <span>Yet Another</span> | ||
}} | ||
</Slotted> | ||
</body> | ||
</html> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.