Merge branch 'main' into pr/17362

pull/17362/head
Rich Harris 3 weeks ago
commit 933d9fc49c

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: don't transform references of function declarations in legacy mode

@ -657,7 +657,8 @@ export function analyze_component(root, source, options) {
if (
binding &&
binding.kind === 'normal' &&
binding.declaration_kind !== 'import'
binding.declaration_kind !== 'import' &&
binding.declaration_kind !== 'function'
) {
binding.kind = 'state';
binding.mutated = true;

@ -54,7 +54,9 @@ export function EachBlock(node, context) {
// collect transitive dependencies...
for (const binding of node.metadata.expression.dependencies) {
collect_transitive_dependencies(binding, node.metadata.transitive_deps);
if (binding.declaration_kind !== 'function') {
collect_transitive_dependencies(binding, node.metadata.transitive_deps);
}
}
// ...and ensure they are marked as state, so they can be turned

@ -0,0 +1,7 @@
import { test } from '../../test';
export default test({
async test({ assert, target }) {
assert.htmlEqual(target.innerHTML, `<input>`);
}
});

@ -0,0 +1,11 @@
<script>
$: items = [{ value: 'hello' }];
function fn(value) {
return true;
}
</script>
{#each items.filter(fn) as item}
<input bind:value={item.value} />
{/each}
Loading…
Cancel
Save