diff --git a/.changeset/flat-melons-protect.md b/.changeset/flat-melons-protect.md new file mode 100644 index 0000000000..43a8c45754 --- /dev/null +++ b/.changeset/flat-melons-protect.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: ensure `$$slots` exists in runes mode diff --git a/packages/svelte/src/compiler/phases/2-analyze/index.js b/packages/svelte/src/compiler/phases/2-analyze/index.js index ef5d807bb9..71295b7059 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/index.js +++ b/packages/svelte/src/compiler/phases/2-analyze/index.js @@ -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 diff --git a/packages/svelte/tests/runtime-runes/samples/slot/_config.js b/packages/svelte/tests/runtime-runes/samples/slot/_config.js new file mode 100644 index 0000000000..c69314e244 --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/slot/_config.js @@ -0,0 +1,6 @@ +import { test } from '../../test'; + +// Test that $$slots exists in runes mode +export default test({ + html: `
bar
` +}); diff --git a/packages/svelte/tests/runtime-runes/samples/slot/main.svelte b/packages/svelte/tests/runtime-runes/samples/slot/main.svelte new file mode 100644 index 0000000000..e6490ab098 --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/slot/main.svelte @@ -0,0 +1,7 @@ + + +bar
+