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: improve namespace inference when having {@render} and {@html} tags #10631

Merged
merged 11 commits into from
Mar 5, 2024

Conversation

navorite
Copy link
Contributor

@navorite navorite commented Feb 25, 2024

When using {@render ...} in a component that has only svg nodes, the namespace gets the maybe_html value which returns the default namespace (html). Instead {@render ...} should be treated like child components, they should not affect the component's namespace.

I also simplified the code a bit.

Svelte 5 rewrite

Please note that the Svelte codebase is currently being rewritten for Svelte 5. Changes should target Svelte 5, which lives on the default branch (main).

If your PR concerns Svelte 4 (including updates to svelte.dev.docs), please ensure the base branch is svelte-4 and not main.

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

Copy link

changeset-bot bot commented Feb 25, 2024

🦋 Changeset detected

Latest commit: 36e01ed

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

@navorite navorite marked this pull request as draft February 25, 2024 08:07
@navorite navorite marked this pull request as ready for review February 25, 2024 08:50
Copy link
Member

@dummdidumm dummdidumm left a comment

Choose a reason for hiding this comment

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

The simplification is great, thank you!
I'm not sure yet if we should change the behavior. Do you have a concrete use case where this yielded wrong results?
If we changed this, shouldn't we also change it for {@html ..}?

packages/svelte/src/compiler/phases/3-transform/utils.js Outdated Show resolved Hide resolved
packages/svelte/src/compiler/phases/3-transform/utils.js Outdated Show resolved Hide resolved
navorite and others added 2 commits February 29, 2024 17:09
Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
@navorite
Copy link
Contributor Author

navorite commented Feb 29, 2024

The simplification is great, thank you! I'm not sure yet if we should change the behavior. Do you have a concrete use case where this yielded wrong results? If we changed this, shouldn't we also change it for {@html ..}?

REPL

I think we should do the same for {@html ..} since this is what happens in Svelte 4 and it also makes more sense. I'll make that change as well.

@navorite navorite changed the title fix: treat snippets like child components when inferring namespace fix: improve namespace inference when having {@render} and {@html} tags Feb 29, 2024
@Rich-Harris Rich-Harris merged commit 6fb64c9 into sveltejs:main Mar 5, 2024
8 checks passed
@Rich-Harris
Copy link
Member

thank you!

@navorite navorite deleted the render-namespace branch March 5, 2024 05:39
@navorite navorite restored the render-namespace branch March 5, 2024 05:39
@navorite navorite deleted the render-namespace branch March 5, 2024 05:39
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.

None yet

3 participants