Skip to content

Commit

Permalink
failing test for #13270
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Sep 19, 2024
1 parent c636fc6 commit f8b3590
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
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'));
}
});
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>

0 comments on commit f8b3590

Please sign in to comment.