mirror of https://github.com/sveltejs/svelte
parent
1eed645919
commit
ea0d80e195
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: consider variables with synthetic store sub as state
|
@ -0,0 +1,11 @@
|
||||
<script>
|
||||
export let store;
|
||||
|
||||
let currentStore;
|
||||
function update(){
|
||||
currentStore = store
|
||||
}
|
||||
</script>
|
||||
|
||||
<button on:click={update}></button>
|
||||
<p>{$currentStore}</p>
|
@ -0,0 +1,29 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { ok, test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, target, window }) {
|
||||
const [btn1, btn2] = target.querySelectorAll('button');
|
||||
const p = target.querySelector('p');
|
||||
|
||||
assert.equal(p?.innerHTML, '');
|
||||
|
||||
flushSync(() => {
|
||||
btn2.click();
|
||||
});
|
||||
|
||||
assert.equal(p?.innerHTML, '1');
|
||||
|
||||
flushSync(() => {
|
||||
btn1.click();
|
||||
});
|
||||
|
||||
assert.equal(p?.innerHTML, '1');
|
||||
|
||||
flushSync(() => {
|
||||
btn2.click();
|
||||
});
|
||||
|
||||
assert.equal(p?.innerHTML, '2');
|
||||
}
|
||||
});
|
@ -0,0 +1,9 @@
|
||||
<script>
|
||||
import { writable } from 'svelte/store'
|
||||
import Test from './Test.svelte'
|
||||
let counter = 1
|
||||
let store = writable(counter)
|
||||
</script>
|
||||
|
||||
<button on:click={() => store = writable(++counter)}></button>
|
||||
<Test {store} />
|
Loading…
Reference in new issue