Skip to content

Commit

Permalink
fix: ensure $$slots exists in runes mode (#9718)
Browse files Browse the repository at this point in the history
fixes #9683
  • Loading branch information
dummdidumm committed Nov 30, 2023
1 parent 4a8f0bc commit cb1ea1f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
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}

1 comment on commit cb1ea1f

@vercel
Copy link

@vercel vercel bot commented on cb1ea1f Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

svelte-5-preview – ./sites/svelte-5-preview

svelte-5-preview-svelte.vercel.app
svelte-5-preview.vercel.app
svelte-5-preview-git-main-svelte.vercel.app
svelte-octane.vercel.app

Please sign in to comment.