-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: reset dependency read versions after reaction execution (#14964)
* fix: reset dependency read versions after reaction execution * fix: reset dependency read versions after reaction execution * fix: reset dependency read versions after reaction execution * fix: reset dependency read versions after reaction execution * fix: reset dependency read versions after reaction execution * chore: add test * changeset --------- Co-authored-by: paoloricciuti <ricciutipaolo@gmail.com> Co-authored-by: Rich Harris <rich.harris@vercel.com>
- Loading branch information
1 parent
b7400ae
commit bdc0200
Showing
5 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
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,5 @@ | ||
--- | ||
'svelte': patch | ||
--- | ||
|
||
fix: reset dependency read versions after reaction execution |
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
7 changes: 7 additions & 0 deletions
7
packages/svelte/tests/runtime-runes/samples/read-version-previous-reaction/Component.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,7 @@ | ||
<script> | ||
const { label = 0, size = 0 } = $props(); | ||
const title = $derived(size.toString()); | ||
</script> | ||
|
||
<p {title}>{label}</p> |
19 changes: 19 additions & 0 deletions
19
packages/svelte/tests/runtime-runes/samples/read-version-previous-reaction/_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,19 @@ | ||
import { ok, test } from '../../test'; | ||
import { flushSync } from 'svelte'; | ||
|
||
export default test({ | ||
html: `<button></button><p title="0">0</p>`, | ||
|
||
async test({ assert, target }) { | ||
const p = target.querySelector('p'); | ||
const btn = target.querySelector('button'); | ||
flushSync(() => { | ||
btn?.click(); | ||
}); | ||
assert.equal(p?.innerHTML, '1'); | ||
flushSync(() => { | ||
btn?.click(); | ||
}); | ||
assert.equal(p?.innerHTML, '2'); | ||
} | ||
}); |
18 changes: 18 additions & 0 deletions
18
packages/svelte/tests/runtime-runes/samples/read-version-previous-reaction/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,18 @@ | ||
<script> | ||
import Component from "./Component.svelte"; | ||
let props = $state({ | ||
label: 0, | ||
size: 0, | ||
}); | ||
let filteredProps = $state(); | ||
$effect.pre(() => { | ||
filteredProps = $state.snapshot(props); | ||
}); | ||
</script> | ||
|
||
<button onclick={()=>props.label++}></button> | ||
|
||
<Component {...filteredProps} /> |