Skip to content

bind:this to each value compiles into undefined variable names #4517

@pushkine

Description

@pushkine
<script>
    const refs = [1,2,3]
</script>

{#each refs as ref}
    <div bind:this={ref}/>
{/each}

ERROR: each_value is not defined

https://svelte.dev/repl/2d4004d1ee40459a9022c97204529bb6?version=3.19.2

in fact neither each_value or ref_index are defined in the compiled code

function instance($$self, $$props, $$invalidate) {
	const refs = [1, 2, 3];

	function div_binding($$value, ref) {
		if (each_value[ref_index] === $$value) return;

		binding_callbacks[$$value ? "unshift" : "push"](() => {
			each_value[ref_index] = $$value;
		});
	}

	return [refs, div_binding];
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions