Skip to content

Commit c66bf17

Browse files
fix: mark subtree dynamic for bind with sequence expressions (#14626)
1 parent c1c59e7 commit c66bf17

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

.changeset/green-pandas-study.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: mark subtree dynamic for bind with sequence expressions

packages/svelte/src/compiler/phases/2-analyze/visitors/BindDirective.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import * as w from '../../../warnings.js';
1111
import { binding_properties } from '../../bindings.js';
1212
import fuzzymatch from '../../1-parse/utils/fuzzymatch.js';
1313
import { is_content_editable_binding, is_svg } from '../../../../utils.js';
14+
import { mark_subtree_dynamic } from './shared/fragment.js';
1415

1516
/**
1617
* @param {AST.BindDirective} node
@@ -141,6 +142,8 @@ export function BindDirective(node, context) {
141142
e.bind_invalid_expression(node);
142143
}
143144

145+
mark_subtree_dynamic(context.path);
146+
144147
return;
145148
}
146149

packages/svelte/tests/runtime-runes/samples/bind-getter-setter/_config.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,23 @@ import { assert_ok } from '../../../suite';
44

55
export default test({
66
async test({ assert, target, logs }) {
7-
const input = target.querySelector('input');
8-
9-
assert_ok(input);
7+
const [input, checkbox] = target.querySelectorAll('input');
108

119
input.value = '2';
1210
input.dispatchEvent(new window.Event('input'));
1311

1412
flushSync();
1513

16-
assert.htmlEqual(target.innerHTML, `<button>a: 2</button><input type="value">`);
14+
assert.htmlEqual(
15+
target.innerHTML,
16+
`<button>a: 2</button><input type="value"><div><input type="checkbox" ></div>`
17+
);
1718

1819
assert.deepEqual(logs, ['b', '2', 'a', '2']);
20+
21+
flushSync(() => {
22+
checkbox.click();
23+
});
24+
assert.deepEqual(logs, ['b', '2', 'a', '2', 'check', false]);
1925
}
2026
});

packages/svelte/tests/runtime-runes/samples/bind-getter-setter/main.svelte

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import Child from './Child.svelte';
33
44
let a = $state(0);
5+
let check = $state(true);
56
</script>
67

78
<button onclick={() => a++}>a: {a}</button>
@@ -14,3 +15,11 @@
1415
}}
1516
/>
1617

18+
<div>
19+
<input type="checkbox"
20+
bind:checked={()=>check,
21+
(v)=>{
22+
console.log('check', v);
23+
check = v;
24+
}} />
25+
</div>

0 commit comments

Comments
 (0)