mirror of https://github.com/sveltejs/svelte
breaking: remove `$state.link` callback (#12942)
* breaking: remove `$state.link` callback * simplify * regeneratepull/12954/head
parent
af35fb7ae6
commit
0b51ff04b0
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
breaking: remove callback from `$state.link`
|
@ -1,38 +0,0 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `<button>0</button><button>0</button><button>false</button>`,
|
||||
|
||||
test({ assert, target }) {
|
||||
const [btn1, btn2, btn3] = target.querySelectorAll('button');
|
||||
|
||||
flushSync(() => btn1.click());
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`<button>1</button><button>1</button><button>false</button>`
|
||||
);
|
||||
|
||||
flushSync(() => btn2.click());
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`<button>1</button><button>2</button><button>false</button>`
|
||||
);
|
||||
|
||||
flushSync(() => btn3.click());
|
||||
assert.htmlEqual(target.innerHTML, `<button>1</button><button>2</button><button>true</button>`);
|
||||
|
||||
flushSync(() => btn1.click());
|
||||
assert.htmlEqual(target.innerHTML, `<button>2</button><button>2</button><button>true</button>`);
|
||||
|
||||
flushSync(() => btn1.click());
|
||||
assert.htmlEqual(target.innerHTML, `<button>3</button><button>2</button><button>true</button>`);
|
||||
|
||||
flushSync(() => btn1.click());
|
||||
flushSync(() => btn3.click());
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`<button>4</button><button>4</button><button>false</button>`
|
||||
);
|
||||
}
|
||||
});
|
@ -1,12 +0,0 @@
|
||||
<script>
|
||||
let a = $state(0);
|
||||
let b = $state.link(a, (value) => {
|
||||
if (c) return;
|
||||
b = value;
|
||||
});
|
||||
let c = $state(false);
|
||||
</script>
|
||||
|
||||
<button onclick={() => a++}>{a}</button>
|
||||
<button onclick={() => b++}>{b}</button>
|
||||
<button onclick={() => c = !c}>{c}</button>
|
Loading…
Reference in new issue