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
15cd894
commit eb05491
Showing
6 changed files
with
80 additions
and
1 deletion.
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
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,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> |
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> |