mirror of https://github.com/sveltejs/svelte
fix: don't emit assignment warnings for bindings (#14651)
Also fixes the possibility of an infinite loop due to the property access during the dev time check fixes #14643pull/14656/head
parent
66e30d3288
commit
88184cd769
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: don't emit assignment warnings for bindings
|
@ -0,0 +1,11 @@
|
|||||||
|
<script>
|
||||||
|
let { x = $bindable() } = $props();
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
x = {};
|
||||||
|
});
|
||||||
|
|
||||||
|
export function soThatTestReturnsAnObject() {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
</script>
|
@ -0,0 +1,16 @@
|
|||||||
|
<script>
|
||||||
|
import Test from './Test.svelte';
|
||||||
|
|
||||||
|
let entries = $state([]);
|
||||||
|
let object = $state({ items: null });
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button onclick={() => (object.items ??= []).push(object.items.length)}>
|
||||||
|
items: {JSON.stringify(object.items)}
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<!-- these should not emit warnings -->
|
||||||
|
<div bind:this={entries[0]}>x</div>
|
||||||
|
<Test bind:this={entries[1]}></Test>
|
||||||
|
<Test bind:this={() => entries[2], (v) => (entries[2] = v)}></Test>
|
||||||
|
<Test bind:x={entries[3]}></Test>
|
@ -1,7 +0,0 @@
|
|||||||
<script>
|
|
||||||
let object = $state({ items: null });
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<button onclick={() => (object.items ??= []).push(object.items.length)}>
|
|
||||||
items: {JSON.stringify(object.items)}
|
|
||||||
</button>
|
|
Loading…
Reference in new issue