mirror of https://github.com/sveltejs/svelte
fix: ensure reactivity system remains consistent with removals (#13087)
* fix: ensure reactivity system remains consistent with removals * more fixes * add testpull/13085/head
parent
2d03dc55c6
commit
6f855e627f
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: ensure reactivity system remains consistent with removals
|
@ -0,0 +1,15 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
test({ assert, target }) {
|
||||
const button = target.querySelector('button');
|
||||
|
||||
flushSync(() => {
|
||||
button?.click();
|
||||
button?.click();
|
||||
button?.click();
|
||||
});
|
||||
assert.htmlEqual(target.innerHTML, `<div>3</div><div>3, 6</div><button>increment</button>`);
|
||||
}
|
||||
});
|
@ -0,0 +1,17 @@
|
||||
<script>
|
||||
import { fromStore } from 'svelte/store';
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
const store = writable(0);
|
||||
|
||||
const value = fromStore(store);
|
||||
</script>
|
||||
|
||||
<div>{$store}</div>
|
||||
|
||||
{#if true}
|
||||
{@const doubled = value.current * 2}
|
||||
<div>{value.current}, {doubled}</div>
|
||||
{/if}
|
||||
|
||||
<button onclick={() => $store++}>increment</button>
|
@ -0,0 +1,15 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
test({ assert, target }) {
|
||||
const button = target.querySelector('button');
|
||||
|
||||
flushSync(() => {
|
||||
button?.click();
|
||||
button?.click();
|
||||
button?.click();
|
||||
});
|
||||
assert.htmlEqual(target.innerHTML, `\n3\n<button>Increment</button><br>`);
|
||||
}
|
||||
});
|
@ -0,0 +1,23 @@
|
||||
<script>
|
||||
import { writable, fromStore } from 'svelte/store';
|
||||
const store = writable(0)
|
||||
const state_from_store= fromStore(store)
|
||||
|
||||
const derived_value= $derived.by(() => {
|
||||
if (state_from_store.current > 10) {
|
||||
return state_from_store.current
|
||||
}
|
||||
else{
|
||||
return 10
|
||||
}
|
||||
})
|
||||
|
||||
function increment() {
|
||||
$store += 1;
|
||||
}
|
||||
</script>
|
||||
|
||||
{state_from_store.current}
|
||||
<button onclick={increment}>Increment</button><br>
|
||||
|
||||
{#if derived_value > 10 }Exceeded 10!{/if}
|
Loading…
Reference in new issue