Skip to content

Conversation

@jrmajor
Copy link
Contributor

@jrmajor jrmajor commented Apr 19, 2024

#11114, but for special elements, so that they're treated more consistently with HTML elements.

I should have opened an issue for that first, so please treat it like a place for discussion. No hard feelings if it doesn't get merged :)

This PR adds warnings only for <svelte:head> and <svelte:fragment>, since these are the only elements that don't really make sense without content.

<svelte:options>, <svelte:window>, <svelte:document> and <svelte:body> should never have content, so I've opened #11245 to treat them like void tags.

<slot> is deprecated anyway.

Other special elements sometimes feel like void tags, and sometimes not, so I didn't touch them:

<!-- components -->
<svelte:self />
<Foo />
<svelte:component this={"foo"} />

<!-- `this` can be bound to both void and non-void tags -->
<svelte:element this="dif" />

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

@changeset-bot
Copy link

changeset-bot bot commented Apr 19, 2024

🦋 Changeset detected

Latest commit: 6ae0a93

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

This PR includes changesets to release 1 package
Name Type
svelte 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

@jrmajor jrmajor marked this pull request as draft April 19, 2024 14:54
@jrmajor
Copy link
Contributor Author

jrmajor commented Apr 19, 2024

Closing, as decided in #11245.

@jrmajor jrmajor closed this Apr 19, 2024
@jrmajor jrmajor deleted the non-void-special branch April 20, 2024 07:01
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.

1 participant