Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}