Snippets have incorrect scope when component variables are used as components
#16708
Development PR
Closes #16708
Before submitting the PR, please make sure you do the following
- It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
- Prefix your PR title with
feat:,fix:,chore:, ordocs:. - This message body should clearly illustrate what problems it solves.
- Ideally, include a test that fails without this PR but passes with it.
- If this PR changes code within
packages/svelte/src, add a changeset (npx changeset).
Tests and linting
- Run the tests with
pnpm testand lint the project withpnpm lint
Issue
Solved
H
hanielu Sep 3, 2025, 5:05 PMDescribe the bug
Snippets don't have the correct scope for when variables are used as components
<script lang="ts">
import { motion } from "./motion.svelte";
const layout = motion;
</script>
<!-- THIS WORKS -->
<!-- <layout.ul>Hello World</layout.ul> -->
<!-- THIS DOESN'T WORK -->
{@render test()}
{#snippet test()}
<layout.ul>Hello World</layout.ul>
{/snippet}
Reproduction
System Info
System:
OS: macOS 15.5
CPU: (12) arm64 Apple M2 Max
Memory: 101.75 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 23.11.0 - /opt/homebrew/bin/node
Yarn: 1.22.21 - /opt/homebrew/bin/yarn
npm: 10.9.2 - /opt/homebrew/bin/npm
pnpm: 10.13.1 - /opt/homebrew/bin/pnpm
bun: 1.2.19 - ~/.bun/bin/bun
Watchman: 2025.04.28.00 - /opt/homebrew/bin/watchman
Browsers:
Chrome: 140.0.7339.80
Edge: 139.0.3405.125
Safari: 18.5
npmPackages:
svelte: ^5.0.0 => 5.38.6
Severity
annoyance
Info
Closed at Sep 11, 2025, 12:20 AM
Assignees None
Labels None
Milestone None