Skip to content

Commit 4cf2d4a

Browse files
authored
fix: ensure each block references to imports are handled correctly (#13892)
1 parent 59ff7f1 commit 4cf2d4a

File tree

5 files changed

+32
-1
lines changed

5 files changed

+32
-1
lines changed

.changeset/curvy-beds-cover.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: ensure each block references to imports are handled correctly

packages/svelte/src/compiler/phases/2-analyze/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,11 @@ export function analyze_component(root, source, options) {
505505
if (is_reference(node, parent)) {
506506
const binding = context.state.scope.get(node.name);
507507

508-
if (binding && binding.kind === 'normal') {
508+
if (
509+
binding &&
510+
binding.kind === 'normal' &&
511+
binding.declaration_kind !== 'import'
512+
) {
509513
binding.kind = 'state';
510514
binding.mutated = binding.updated = true;
511515
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
html: `<input type="text">`,
5+
ssrHtml: `<input type="text" value="">`
6+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<script>
2+
import { foo } from './utils';
3+
</script>
4+
5+
{#each foo.bar as bar}
6+
<input type="text" bind:value={bar.value} />
7+
{/each}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export const foo = {
2+
get bar() {
3+
return [
4+
{
5+
value: ''
6+
}
7+
];
8+
}
9+
};

0 commit comments

Comments
 (0)