Skip to content

Commit ec4d38e

Browse files
committed
fix: visit expression for svelte:component references
1 parent 3b88b88 commit ec4d38e

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

.changeset/brave-doors-compete.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: visit expression for `svelte:component` references

packages/svelte/src/compiler/phases/scope.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,10 @@ export function create_scopes(ast, root, allow_reactive_declarations, parent) {
305305
default: context.state.scope.child()
306306
};
307307

308+
if (node.type === 'SvelteComponent') {
309+
context.visit(node.expression);
310+
}
311+
308312
const default_state = determine_slot(node)
309313
? context.state
310314
: { scope: node.metadata.scopes.default };
@@ -353,7 +357,6 @@ export function create_scopes(ast, root, allow_reactive_declarations, parent) {
353357
references.push([state.scope, { node, path: path.slice() }]);
354358
}
355359
},
356-
357360
LabeledStatement(node, { path, next }) {
358361
if (path.length > 1 || !allow_reactive_declarations) return next();
359362
if (node.label.name !== '$') return next();
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script>
2+
export let Component;
3+
</script>
4+
5+
<svelte:component this={Component} />
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]

0 commit comments

Comments
 (0)