fix: only emit binding_property_non_reactive warning in runes mode (#12544)

pull/12536/head
Rich Harris 5 months ago committed by GitHub
parent fd5cfd77d8
commit 73ac4fe456
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: only emit binding_property_non_reactive warning in runes mode

@ -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,

@ -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, `<input><p>hello</p>`);
const input = target.querySelector('input');
ok(input);
input.value = 'goodbye';
input.dispatchEvent(new window.Event('input'));
flushSync();
assert.htmlEqual(target.innerHTML, `<input><p>goodbye</p>`);
},
warnings: []
});

@ -0,0 +1,6 @@
<script>
let object = { value: 'hello' };
</script>
<input bind:value={object.value} />
<p>{object.value}</p>
Loading…
Cancel
Save