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: adjust missing inner content warning with svelte v5 #11380

Merged
merged 1 commit into from
Dec 18, 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/brave-waves-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@sveltejs/kit": patch
---

fix: adjust missing inner content warning with svelte v5
8 changes: 6 additions & 2 deletions packages/kit/src/exports/vite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,14 @@ const warning_preprocessor = {
if (!filename) return;

const basename = path.basename(filename);
if (basename.startsWith('+layout.') && !content.includes('<slot')) {
if (
basename.startsWith('+layout.') &&
!content.includes(isSvelte5Plus() ? '{@render children(' : '<slot')
Copy link
Member

Choose a reason for hiding this comment

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

This will catch {@render children(), but do we also need to catch things with different spacing?

{@render
    children()

Copy link
Member

Choose a reason for hiding this comment

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

let { children: meddlingKids } = $props();
{@render meddlingKids()}

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I didn't even think about that. I merged this too quickly.

) {
const message =
`\n${colors.bold().red(path.relative('.', filename))}\n` +
'`<slot />` missing — inner content will not be rendered';
`\`${isSvelte5Plus() ? '{@render children()' : '<slot />'}\`` +
' missing — inner content will not be rendered';

if (!warned.has(message)) {
console.log(message);
Expand Down
Loading