Skip to content

Commit

Permalink
fix: do not warn for binding_property_non_reactive if binding is a …
Browse files Browse the repository at this point in the history
…store in an each (#15318)

Fixes #15315
  • Loading branch information
paoloricciuti authored Feb 17, 2025
1 parent 87d7cc7 commit dde8603
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/little-laws-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: do not warn for `binding_property_non_reactive` if binding is a store in an each
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export interface ComponentClientTransformState extends ClientTransformState {
readonly hoisted: Array<Statement | ModuleDeclaration>;
readonly events: Set<string>;
readonly is_instance: boolean;
readonly store_to_invalidate?: string;

/** Stuff that happens before the render effect(s) */
readonly init: Statement[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ export function EachBlock(node, context) {

const child_state = {
...context.state,
transform: { ...context.state.transform }
transform: { ...context.state.transform },
store_to_invalidate
};

/** The state used when generating the key function, if necessary */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,16 @@ export function validate_binding(state, binding, expression) {

const loc = locator(binding.start);

const obj = /** @type {Expression} */ (expression.object);

state.init.push(
b.stmt(
b.call(
'$.validate_binding',
b.literal(state.analysis.source.slice(binding.start, binding.end)),
b.thunk(/** @type {Expression} */ (expression.object)),
b.thunk(
state.store_to_invalidate ? b.sequence([b.call('$.mark_store_binding'), obj]) : obj
),
b.thunk(
/** @type {Expression} */ (
expression.computed
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { test } from '../../test';

export default test({
compileOptions: {
dev: true
},
async test({ assert, warnings }) {
assert.deepEqual(warnings, []);
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<svelte:options runes />
<script>
import { writable } from 'svelte/store';
const array = writable([{ name: "" }]);
</script>

{#each $array as item}
<div><input bind:value={item.name} /></div>
{/each}

0 comments on commit dde8603

Please sign in to comment.