mirror of https://github.com/sveltejs/svelte
failing test for #13270
parent
c636fc67bc
commit
f8b359014c
@ -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'));
|
||||||
|
}
|
||||||
|
});
|
@ -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>
|
Loading…
Reference in new issue