Skip to content

Commit 73ac4fe

Browse files
authored
fix: only emit binding_property_non_reactive warning in runes mode (#12544)
1 parent fd5cfd7 commit 73ac4fe

File tree

4 files changed

+44
-2
lines changed

4 files changed

+44
-2
lines changed

.changeset/two-keys-watch.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: only emit binding_property_non_reactive warning in runes mode

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,11 @@ function serialize_inline_component(node, component_name, context, anchor = cont
780780
} else if (attribute.type === 'BindDirective') {
781781
const expression = /** @type {Expression} */ (context.visit(attribute.expression));
782782

783-
if (expression.type === 'MemberExpression' && context.state.options.dev) {
783+
if (
784+
expression.type === 'MemberExpression' &&
785+
context.state.options.dev &&
786+
context.state.analysis.runes
787+
) {
784788
context.state.init.push(serialize_validate_binding(context.state, attribute, expression));
785789
}
786790

@@ -2826,7 +2830,11 @@ export const template_visitors = {
28262830
const { state, path, visit } = context;
28272831
const expression = node.expression;
28282832

2829-
if (expression.type === 'MemberExpression' && context.state.options.dev) {
2833+
if (
2834+
expression.type === 'MemberExpression' &&
2835+
context.state.options.dev &&
2836+
context.state.analysis.runes
2837+
) {
28302838
context.state.init.push(
28312839
serialize_validate_binding(
28322840
context.state,
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { flushSync } from 'svelte';
2+
import { ok, test } from '../../test';
3+
4+
export default test({
5+
compileOptions: {
6+
dev: true
7+
},
8+
9+
test({ assert, target, window }) {
10+
assert.htmlEqual(target.innerHTML, `<input><p>hello</p>`);
11+
12+
const input = target.querySelector('input');
13+
ok(input);
14+
15+
input.value = 'goodbye';
16+
input.dispatchEvent(new window.Event('input'));
17+
18+
flushSync();
19+
assert.htmlEqual(target.innerHTML, `<input><p>goodbye</p>`);
20+
},
21+
22+
warnings: []
23+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<script>
2+
let object = { value: 'hello' };
3+
</script>
4+
5+
<input bind:value={object.value} />
6+
<p>{object.value}</p>

0 commit comments

Comments
 (0)