-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: properly add owners to function bindings (#14962)
Closes #14956
- Loading branch information
1 parent
68cffa8
commit c0842d1
Showing
5 changed files
with
59 additions
and
10 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: properly add owners to function bindings |
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
5 changes: 5 additions & 0 deletions
5
packages/svelte/tests/runtime-runes/samples/ownership-function-bindings/Child.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,5 @@ | ||
<script> | ||
let { arr = $bindable() } = $props(); | ||
</script> | ||
|
||
<button onclick={() => arr.push(arr.length)}></button> |
20 changes: 20 additions & 0 deletions
20
packages/svelte/tests/runtime-runes/samples/ownership-function-bindings/_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,20 @@ | ||
import { flushSync } from 'svelte'; | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
compileOptions: { | ||
dev: true | ||
}, | ||
test({ target, warnings, assert }) { | ||
const btn = target.querySelector('button'); | ||
flushSync(() => { | ||
btn?.click(); | ||
}); | ||
assert.deepEqual(warnings, []); | ||
|
||
flushSync(() => { | ||
btn?.click(); | ||
}); | ||
assert.deepEqual(warnings, []); | ||
} | ||
}); |
10 changes: 10 additions & 0 deletions
10
packages/svelte/tests/runtime-runes/samples/ownership-function-bindings/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,10 @@ | ||
<script> | ||
import Child from './Child.svelte'; | ||
let arr = $state([]); | ||
let arr2 = $state([]); | ||
let len = $derived(arr.length + arr2.length); | ||
</script> | ||
|
||
<Child bind:arr={() => len % 2 === 0 ? arr : arr2, (v) => {}} /> |