fix: reevaluate namespace in slots#11849
Conversation
🦋 Changeset detectedLatest commit: 50ec0bd The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
dummdidumm
left a comment
There was a problem hiding this comment.
Thank you - you're right, we need to reevaluate our approach.
I think what we need to do is to create separate templates as soon as we detect SVG and HTML is mixed. Will open an issue.
|
Ok I was about to open an issue but noticed it's kinda unnecessary because mixing HTML and SVG like that is wrong (happy to be proven wrong). Pasting it here: As soon as there's an html element in the component the whole component namespace goes to html. Input: <circle cx={10} cy={10} r={5} />
<button></button>Output right now: var root = $.template(`<circle></circle> <button></button>`, 1); // this is a template with the html namespaceQuestion: Is that correct? We have several options: Separate templatesCreate separate var root1 = $.svg_template(`<circle></circle>`, 1);
var root2 = $.template(` <button></button>`, 1);Then each of those has its correct namespace. Namespace becomes SVGThe namespace becomes SVG if there's a top level SVG element that is not Keep as is / do nothingMixing an SVG element that is not My vote is to do nothing, because as pointed out it's invalid anyway. |
I agree that it should be invalid...if you look at the svelte 4 repl the button is nowhere to be seen so there's still a "bug"...i was just pointing out that the behaviour is different from svelte 4 so it should be listed as a breaking. |
|
That said html behaviour seems to be like svelte 4. |
Svelte 5 rewrite
Closes #11847
This is the simple fix for the issue but i think there's a more fondamental issue that we either have to fix or list as a breaking from svelte 4. As soon as there's an html element in the component the whole component namespace goes to html.
Svelte 5 repl
Svelte 4 repl
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-4and notmain.Before submitting the PR, please make sure you do the following
feat:,fix:,chore:, ordocs:.Tests and linting
pnpm testand lint the project withpnpm lint