-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c636fc6
commit f8b3590
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
...svelte/tests/runtime-runes/samples/dynamic-attribute-and-attribute-directive-2/_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,19 @@ | ||
import { flushSync } from 'svelte'; | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
test({ target, logs, assert }) { | ||
const div = target.querySelector('div'); | ||
const button = target.querySelector('button'); | ||
|
||
assert.deepEqual(logs, ['updated attribute', 'updated directive']); | ||
|
||
assert.ok(div?.classList.contains('dark')); | ||
assert.ok(div?.classList.contains('small')); | ||
|
||
flushSync(() => button?.click()); | ||
assert.deepEqual(logs, ['updated attribute', 'updated directive', 'updated attribute']); | ||
assert.ok(div?.classList.contains('dark')); | ||
assert.ok(div?.classList.contains('big')); | ||
} | ||
}); |
16 changes: 16 additions & 0 deletions
16
...velte/tests/runtime-runes/samples/dynamic-attribute-and-attribute-directive-2/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> | ||
let value = $state(0); | ||
function dark(){ | ||
console.log('updated directive'); | ||
return true; | ||
} | ||
function get_class(){ | ||
console.log('updated attribute'); | ||
return value % 2 ? 'big' : 'small'; | ||
} | ||
</script> | ||
|
||
<div class:dark={dark()} class={get_class()}></div> | ||
<button onclick={()=> value++}>switch</button> |