-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix to apply class directive for svelte:element (#7531)
- Loading branch information
1 parent
5242ab9
commit 6776fe0
Showing
4 changed files
with
41 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
13 changes: 13 additions & 0 deletions
13
test/runtime/samples/dynamic-element-class-directive/Link.svelte
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,13 @@ | ||
<script> | ||
export let item; | ||
</script> | ||
|
||
<svelte:element this="div" class:active={true}> | ||
{item.text} | ||
</svelte:element> | ||
|
||
<style> | ||
.active { | ||
color: red; | ||
} | ||
</style> |
11 changes: 11 additions & 0 deletions
11
test/runtime/samples/dynamic-element-class-directive/_config.js
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,11 @@ | ||
export default { | ||
html: ` | ||
<div class="svelte-1vsuzn0 active">foo</div> | ||
<div class="svelte-1vsuzn0 active">foo0</div> | ||
<div class="svelte-1vsuzn0 active">foo0</div> | ||
<div class="svelte-1vsuzn0 active">foo0</div> | ||
<div class="svelte-1vsuzn0 active">foo1</div> | ||
<div class="svelte-1vsuzn0 active">foo2</div> | ||
<div class="svelte-1vsuzn0 active">foo3</div> | ||
` | ||
}; |
16 changes: 16 additions & 0 deletions
16
test/runtime/samples/dynamic-element-class-directive/main.svelte
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,16 @@ | ||
<script> | ||
import Link from "./Link.svelte"; | ||
let foo = [ | ||
{ text: "foo0" }, | ||
{ text: "foo1" }, | ||
{ text: "foo2" }, | ||
{ text: "foo3" }, | ||
]; | ||
</script> | ||
|
||
<Link item={{ text: "foo" }} /> | ||
<Link item={foo[0]} /> | ||
<Link bind:item={foo[0]} /> | ||
{#each foo as item} | ||
<Link bind:item /> | ||
{/each} |