Skip to content

Commit 94ed096

Browse files
trueadmRich-Harris
andauthored
fix: correctly ensure prop bindings are reactive when bound (#12879)
* fix: correctly ensure prop bindings are reactive when bound * oops * Apply suggestions from code review * Update packages/svelte/src/compiler/phases/3-transform/client/utils.js --------- Co-authored-by: Rich Harris <[email protected]>
1 parent cb75b5c commit 94ed096

File tree

5 files changed

+42
-1
lines changed

5 files changed

+42
-1
lines changed

.changeset/eighty-days-wave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: correctly ensure prop bindings are reactive when bound

packages/svelte/src/compiler/phases/3-transform/client/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export function get_prop_source(binding, state, name, initial) {
186186
state.analysis.accessors ||
187187
(state.analysis.immutable
188188
? binding.reassigned || (state.analysis.runes && binding.mutated)
189-
: binding.mutated)
189+
: binding.updated)
190190
) {
191191
flags |= PROPS_IS_UPDATED;
192192
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script>
2+
export let value;
3+
</script>
4+
5+
<input type="text" bind:value />
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { flushSync } from 'svelte';
2+
import { ok, test } from '../../test';
3+
4+
export default test({
5+
accessors: false,
6+
html: `<input type="text">\naaa`,
7+
ssrHtml: `<input type="text" value="aaa">\naaa`,
8+
9+
test({ assert, target }) {
10+
const input = target.querySelector('input');
11+
ok(input);
12+
13+
const event = new window.Event('input');
14+
15+
input.value = 'aaa2';
16+
input.dispatchEvent(event);
17+
18+
flushSync();
19+
20+
assert.htmlEqual(target.innerHTML, `<input type="text">\naaa2`);
21+
}
22+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<script>
2+
import Field from './Field.svelte';
3+
import { writable } from 'svelte/store';
4+
5+
const value = writable('aaa');
6+
7+
</script>
8+
9+
<Field bind:value={$value} /> {$value}

0 commit comments

Comments
 (0)