fix: correctly ensure prop bindings are reactive when bound

pull/12879/head
Dominic Gannaway 2 years ago
parent 686b0865c5
commit 2e74928410

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: correctly ensure prop bindings are reactive when bound

@ -184,6 +184,7 @@ export function get_prop_source(binding, state, name, initial) {
if (
state.analysis.accessors ||
binding.updated ||
(state.analysis.immutable
? binding.reassigned || (state.analysis.runes && binding.mutated)
: binding.mutated)

@ -0,0 +1,5 @@
<script>
export let value;
</script>
<input type="text" bind:value />

@ -0,0 +1,21 @@
import { flushSync } from 'svelte';
import { ok, test } from '../../test';
export default test({
html: `<input type="text">\naaa`,
ssrHtml: `<input type="text" value="aaa">\naaa`,
test({ assert, target }) {
const input = target.querySelector('input');
ok(input);
const event = new window.Event('input');
input.value = 'aaa2';
input.dispatchEvent(event);
flushSync();
assert.htmlEqual(target.innerHTML, `<input type="text">\naaa2`);
}
});

@ -0,0 +1,9 @@
<script>
import Field from './Field.svelte';
import { writable } from 'svelte/store';
const value = writable('aaa');
</script>
<Field bind:value={$value} /> {$value}
Loading…
Cancel
Save