Skip to content

Commit

Permalink
fix: only emit binding_property_non_reactive warning in runes mode (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris authored Jul 22, 2024
1 parent fd5cfd7 commit 73ac4fe
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/two-keys-watch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: only emit binding_property_non_reactive warning in runes mode
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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: []
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<script>
let object = { value: 'hello' };
</script>

<input bind:value={object.value} />
<p>{object.value}</p>

0 comments on commit 73ac4fe

Please sign in to comment.