diff --git a/.changeset/two-keys-watch.md b/.changeset/two-keys-watch.md new file mode 100644 index 0000000000..92a455e07b --- /dev/null +++ b/.changeset/two-keys-watch.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: only emit binding_property_non_reactive warning in runes mode diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js index 4683a945bd..84c0ad0ed5 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js @@ -780,7 +780,11 @@ function serialize_inline_component(node, component_name, context, anchor = cont } else if (attribute.type === 'BindDirective') { const expression = /** @type {Expression} */ (context.visit(attribute.expression)); - if (expression.type === 'MemberExpression' && context.state.options.dev) { + if ( + expression.type === 'MemberExpression' && + context.state.options.dev && + context.state.analysis.runes + ) { context.state.init.push(serialize_validate_binding(context.state, attribute, expression)); } @@ -2826,7 +2830,11 @@ export const template_visitors = { const { state, path, visit } = context; const expression = node.expression; - if (expression.type === 'MemberExpression' && context.state.options.dev) { + if ( + expression.type === 'MemberExpression' && + context.state.options.dev && + context.state.analysis.runes + ) { context.state.init.push( serialize_validate_binding( context.state, diff --git a/packages/svelte/tests/runtime-legacy/samples/binding-member-expression-no-warning/_config.js b/packages/svelte/tests/runtime-legacy/samples/binding-member-expression-no-warning/_config.js new file mode 100644 index 0000000000..e99efacba8 --- /dev/null +++ b/packages/svelte/tests/runtime-legacy/samples/binding-member-expression-no-warning/_config.js @@ -0,0 +1,23 @@ +import { flushSync } from 'svelte'; +import { ok, test } from '../../test'; + +export default test({ + compileOptions: { + dev: true + }, + + test({ assert, target, window }) { + assert.htmlEqual(target.innerHTML, `
hello
`); + + const input = target.querySelector('input'); + ok(input); + + input.value = 'goodbye'; + input.dispatchEvent(new window.Event('input')); + + flushSync(); + assert.htmlEqual(target.innerHTML, `goodbye
`); + }, + + warnings: [] +}); diff --git a/packages/svelte/tests/runtime-legacy/samples/binding-member-expression-no-warning/main.svelte b/packages/svelte/tests/runtime-legacy/samples/binding-member-expression-no-warning/main.svelte new file mode 100644 index 0000000000..5277309402 --- /dev/null +++ b/packages/svelte/tests/runtime-legacy/samples/binding-member-expression-no-warning/main.svelte @@ -0,0 +1,6 @@ + + + +{object.value}