-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "breaking: remove
$state.link
callback (#12942)"
This reverts commit 0b51ff0.
- Loading branch information
1 parent
0b51ff0
commit 85871d7
Showing
9 changed files
with
110 additions
and
10 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
packages/svelte/tests/runtime-runes/samples/state-link-callback/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
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>` | ||
); | ||
} | ||
}); |
12 changes: 12 additions & 0 deletions
12
packages/svelte/tests/runtime-runes/samples/state-link-callback/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters