fix: improve prop binding warning validation for stores

pull/12745/head
Dominic Gannaway 2 years ago
parent 98ae05b569
commit e7d510a534

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: improve prop binding warning validation for stores

@ -214,6 +214,11 @@ export function client_component(analysis, options) {
: b.thunk(store_get)
)
);
if (dev) {
store_setup.push(
b.stmt(b.assignment('=', b.member(binding.node, b.id('$is_store')), b.literal(true)))
);
}
}
}

@ -105,7 +105,7 @@ export function validate_binding(binding, get_object, get_property, line, column
var filename = dev_current_component_function?.[FILENAME];
render_effect(() => {
if (warned) return;
if (warned || get_object.$is_store) return;
var object = get_object();
var property = get_property();

@ -0,0 +1,5 @@
<script>
let { count = $bindable() } = $props();
</script>
<input type="number" bind:value={count} />

@ -0,0 +1,11 @@
import { test } from '../../test';
export default test({
mode: ['client'],
compileOptions: {
dev: true
},
async test({ warnings, assert }) {
assert.deepEqual(warnings, []);
}
});

@ -0,0 +1,9 @@
<script>
import { writable } from 'svelte/store';
import Child from './Child.svelte';
let stuff = writable({ count: 0 });
</script>
<Child bind:count={$stuff.count} />
<p>{$stuff.count}</p>
Loading…
Cancel
Save