Skip to content

Conversation

@FrankFMY
Copy link
Contributor

@FrankFMY FrankFMY commented Feb 6, 2026

Summary

Fixes #13504

When a +layout.svelte forwards children to a child component instead of rendering it directly with {@render children()}, the warning "<slot /> or {@render ...} tag missing — inner content will not be rendered`" fires as a false positive.

This PR suppresses the warning when children is passed to a child component via:

  • Shorthand prop: <Layout {children} />
  • Explicit prop: <Layout children={children} />

As suggested by @elliott-with-the-longest-name-on-github in the issue discussion.

Changes

  • packages/kit/src/exports/vite/index.js — Extend has_children check to detect {children} and children={ patterns in markup
  • packages/kit/src/exports/vite/static_analysis/utils.spec.js — Add unit tests for children forwarding detection

Test plan

  • Unit tests added for all forwarding patterns (shorthand, explicit, negative cases)
  • pnpm -F @sveltejs/kit test:unit — 424 tests passed
  • pnpm run format — clean

When a +layout.svelte passes children to a child component via
shorthand ({children}) or explicit prop (children={children}),
the "inner content will not be rendered" warning no longer fires.

Closes sveltejs#13504
@changeset-bot
Copy link

changeset-bot bot commented Feb 6, 2026

🦋 Changeset detected

Latest commit: acb0b5a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@svelte-docs-bot
Copy link

Comment on lines 157 to 169
// Recreate the markup children detection logic for testing (mirrors warning_preprocessor in vite/index.js)
/**
* @param {string} content
* @returns {boolean}
*/
function has_children(content) {
return (
content.includes('<slot') ||
content.includes('{@render') ||
content.includes('{children}') ||
content.includes('children={')
);
}
Copy link
Member

Choose a reason for hiding this comment

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

No, this is a very bad idea, this will drift. If we want tests for this then the logic in vite/index.js should be extracted out into a function in utils.js and be imported/tested here

Copy link
Contributor Author

@FrankFMY FrankFMY left a comment

Choose a reason for hiding this comment

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

Done — extracted has_children into utils.js and imported it in both index.js and the test file.

@dummdidumm dummdidumm merged commit 5d05ca6 into sveltejs:main Feb 6, 2026
22 checks passed
@github-actions github-actions bot mentioned this pull request Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Svelte 5: missing inner content warning if children prop is forwarded

2 participants