Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure $$slots exists in runes mode #9718

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/flat-melons-protect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: ensure `$$slots` exists in runes mode
5 changes: 5 additions & 0 deletions packages/svelte/src/compiler/phases/2-analyze/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,11 @@ const common_visitors = {
const parent = /** @type {import('estree').Node} */ (context.path.at(-1));
if (!is_reference(node, parent)) return;

if (node.name === '$$slots') {
context.state.analysis.uses_slots = true;
return;
}

const binding = context.state.scope.get(node.name);

// if no binding, means some global variable
Expand Down
6 changes: 6 additions & 0 deletions packages/svelte/tests/runtime-runes/samples/slot/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { test } from '../../test';

// Test that $$slots exists in runes mode
export default test({
html: `<p>bar</p>`
});
7 changes: 7 additions & 0 deletions packages/svelte/tests/runtime-runes/samples/slot/main.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script>
import Slot from './slot.svelte';
</script>

<Slot>
<p>bar</p>
</Slot>
3 changes: 3 additions & 0 deletions packages/svelte/tests/runtime-runes/samples/slot/slot.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{#if $$slots}
<slot></slot>
{/if}