mirror of https://github.com/sveltejs/svelte
breaking: remove `$state.link` (#12943)
* Revert "breaking: remove `$state.link` callback (#12942)" This reverts commitpull/12957/head0b51ff04b0
. * Revert "feat: adds $state.link rune (#12545)" This reverts commit63ec2e2e88
. * put changesets back * changeset * merge main
parent
af7f90020d
commit
9f962d6f81
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
breaking: remove `$state.link` rune pending further design work
|
@ -1,19 +0,0 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `<button>0</button><button>0</button>`,
|
||||
|
||||
test({ assert, target }) {
|
||||
const [btn1, btn2] = target.querySelectorAll('button');
|
||||
|
||||
flushSync(() => btn1.click());
|
||||
assert.htmlEqual(target.innerHTML, `<button>1</button><button>1</button>`);
|
||||
|
||||
flushSync(() => btn2.click());
|
||||
assert.htmlEqual(target.innerHTML, `<button>1</button><button>2</button>`);
|
||||
|
||||
flushSync(() => btn1.click());
|
||||
assert.htmlEqual(target.innerHTML, `<button>2</button><button>2</button>`);
|
||||
}
|
||||
});
|
@ -1,11 +0,0 @@
|
||||
<script>
|
||||
class Instance {
|
||||
a = $state(0);
|
||||
b = $state.link(this.a);
|
||||
}
|
||||
|
||||
const instance = new Instance();
|
||||
</script>
|
||||
|
||||
<button onclick={() => instance.a++}>{instance.a}</button>
|
||||
<button onclick={() => instance.b++}>{instance.b}</button>
|
@ -1,24 +0,0 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `<button>0</button><button>0</button><button>0</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>1</button>`);
|
||||
|
||||
// mutate the original object, via the link
|
||||
flushSync(() => btn2.click());
|
||||
assert.htmlEqual(target.innerHTML, `<button>2</button><button>2</button><button>2</button>`);
|
||||
|
||||
// mutate the copy
|
||||
flushSync(() => btn3.click());
|
||||
assert.htmlEqual(target.innerHTML, `<button>2</button><button>2</button><button>3</button>`);
|
||||
|
||||
flushSync(() => btn1.click());
|
||||
assert.htmlEqual(target.innerHTML, `<button>3</button><button>3</button><button>3</button>`);
|
||||
}
|
||||
});
|
@ -1,9 +0,0 @@
|
||||
<script>
|
||||
let a = $state({ value: 0 });
|
||||
let b = $state.link(a);
|
||||
let c = $state.link({ ...a });
|
||||
</script>
|
||||
|
||||
<button onclick={() => a.value++}>{a.value}</button>
|
||||
<button onclick={() => b.value++}>{b.value}</button>
|
||||
<button onclick={() => c.value++}>{c.value}</button>
|
@ -1,19 +0,0 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `<button>0</button><button>0</button>`,
|
||||
|
||||
test({ assert, target }) {
|
||||
const [btn1, btn2] = target.querySelectorAll('button');
|
||||
|
||||
flushSync(() => btn1.click());
|
||||
assert.htmlEqual(target.innerHTML, `<button>1</button><button>1</button>`);
|
||||
|
||||
flushSync(() => btn2.click());
|
||||
assert.htmlEqual(target.innerHTML, `<button>1</button><button>2</button>`);
|
||||
|
||||
flushSync(() => btn1.click());
|
||||
assert.htmlEqual(target.innerHTML, `<button>2</button><button>2</button>`);
|
||||
}
|
||||
});
|
@ -1,7 +0,0 @@
|
||||
<script>
|
||||
let a = $state(0);
|
||||
let b = $state.link(a);
|
||||
</script>
|
||||
|
||||
<button onclick={() => a++}>{a}</button>
|
||||
<button onclick={() => b++}>{b}</button>
|
Loading…
Reference in new issue