-
-
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: ensure tracking returns true, even if in unowned (#15214)
* fix: ensure tracking returns true, even if in unowned * fix: ensure tracking returns true, even if in unowned * Update packages/svelte/tests/runtime-runes/samples/effect-tracking-unowned/main.svelte --------- Co-authored-by: Simon H <[email protected]>
- Loading branch information
1 parent
f67cf20
commit d39d8c0
Showing
4 changed files
with
34 additions
and
7 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: ensure tracking returns true, even if in unowned |
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
16 changes: 16 additions & 0 deletions
16
packages/svelte/tests/runtime-runes/samples/effect-tracking-unowned/_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,16 @@ | ||
import { flushSync } from 'svelte'; | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
async test({ assert, target, logs }) { | ||
const b1 = target.querySelector('button'); | ||
|
||
b1?.click(); | ||
flushSync(); | ||
|
||
assert.htmlEqual( | ||
target.innerHTML, | ||
`<o>Store: new</o><p>Text: new message</p><button>Change Store</button>` | ||
); | ||
} | ||
}); |
12 changes: 12 additions & 0 deletions
12
packages/svelte/tests/runtime-runes/samples/effect-tracking-unowned/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> | ||
import { writable, fromStore, toStore } from "svelte/store"; | ||
const store = writable("previous"); | ||
let text = $derived(fromStore(store).current + " message"); | ||
text; // read derived in a non-tracking context | ||
</script> | ||
|
||
<o>Store: {$store}</o> | ||
<p>Text: {text}</p> | ||
<button onclick={() => { store.set("new"); }}>Change Store</button> |