-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
svelte:element
doesn't work as expected with svelte
namespaced elements
#7575
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
Comments
I'm labeling this "docs" because mentioning this in the docs is the most we'd want to do here. I'm personally -0.5 on mentioning this in the docs, but could be swayed by other maintainers. |
What is the use case of this? This is a personal opinion, but I feel that including this in the documentation would make more noise than information gained. |
I was working on a component which had data that could be placed into either the header or body, depending on a prop, kinda like: <script>
export let output;
export let data;
</script>
<#if output === "head">
<svelte:head>
<@html data>
<!-- other html... -->
</svelte:head>
<:else>
<div>
<@html data>
<!-- other html... -->
</div>
</if> and I thought that I could remove the repeated html (a lot longer than this example) with code like <script>
export let output;
export let data;
$: element = output === "head" ? "svelte:head" : "div"
</script>
<svelte:element this={element}>
<@html data>
<!-- other html... -->
</svelte:element> We could just add a line to the documentation for
|
Describe the bug
Svelte seems to process svelte namespaced elements like
svelte:head
beforesvelte:element
, causing elements liketo be directly output into the body of the DOM as
Reproduction
REPL here to show how elements don't get placed into
head
orbody
correctly.Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: