fix: do not warn for `binding_property_non_reactive` if binding is a store in an each (#15318)

Fixes #15315
pull/15319/head
Paolo Ricciuti 7 months ago committed by GitHub
parent 87d7cc7d89
commit dde8603872
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: do not warn for `binding_property_non_reactive` if binding is a store in an each

@ -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[];

@ -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 */

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

@ -0,0 +1,10 @@
import { test } from '../../test';
export default test({
compileOptions: {
dev: true
},
async test({ assert, warnings }) {
assert.deepEqual(warnings, []);
}
});

@ -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}
Loading…
Cancel
Save