-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Top level {@html ...} not working if component rendered to ShadowRoot #8038
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
The reason fo this seems to be, that svelte/src/runtime/internal/dom.ts Lines 698 to 711 in b05b684
But the shadowRoot element is special and has only If one wants to create a element of the same type as the target, an alternative would be to use the host type. Possibely something like this: m(
html: string,
target: HTMLElement | SVGElement | ShadowRoot,
anchor: HTMLElement | SVGElement = null
) {
if (!this.e) {
if (this.is_svg) this.e = svg_element(target.nodeName as keyof SVGElementTagNameMap);
else if ("host" in target) this.e = element(target.host.nodeName as keyof HTMLElementTagNameMap);
else this.e = element(target.nodeName as keyof HTMLElementTagNameMap);
this.t = target;
this.c(html);
}
this.i(anchor);
} |
Describe the bug
If a Svelte component is rendered to a ShadowRoot, it is not possible to create a top level
{@html ...}
tag.The element creation fails with:
It works if
{@html ...}
is wrapped by another element.Reproduction
https://stackblitz.com/edit/vitejs-vite-wc4uwt?file=src/App.svelte
Logs
System Info
The text was updated successfully, but these errors were encountered: