fix: visit expression for `svelte:component` references (#13151)

Fixes #13148
pull/13152/head
Paolo Ricciuti 4 months ago committed by GitHub
parent 3b88b88886
commit 53a90fb8c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: visit expression for `svelte:component` references

@ -305,6 +305,10 @@ export function create_scopes(ast, root, allow_reactive_declarations, parent) {
default: context.state.scope.child()
};
if (node.type === 'SvelteComponent') {
context.visit(node.expression);
}
const default_state = determine_slot(node)
? context.state
: { scope: node.metadata.scopes.default };
@ -353,7 +357,6 @@ export function create_scopes(ast, root, allow_reactive_declarations, parent) {
references.push([state.scope, { node, path: path.slice() }]);
}
},
LabeledStatement(node, { path, next }) {
if (path.length > 1 || !allow_reactive_declarations) return next();
if (node.label.name !== '$') return next();

@ -0,0 +1,5 @@
<script>
export let Component;
</script>
<svelte:component this={Component} />
Loading…
Cancel
Save