From 9f368bc201fbb85e4c51df374913d33e9997e3d1 Mon Sep 17 00:00:00 2001
From: lidlanca <8693091+lidlanca@users.noreply.github.com>
Date: Sun, 17 Apr 2022 22:33:51 +0000
Subject: [PATCH] HtmlTag::m normalize the case target is a fragment of
template
---
src/runtime/internal/dom.ts | 5 +++--
test/runtime/samples/template/main.svelte | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/runtime/internal/dom.ts b/src/runtime/internal/dom.ts
index eee5d574fa..a7418ab278 100644
--- a/src/runtime/internal/dom.ts
+++ b/src/runtime/internal/dom.ts
@@ -664,7 +664,8 @@ export class HtmlTag {
m(html: string, target: HTMLElement, anchor: HTMLElement = null) {
if (!this.e) {
- this.e = element(target.nodeName as keyof HTMLElementTagNameMap);
+ /** #7364 target for may be provided as #document-fragment(11) */
+ this.e = element((target.nodeType === 11 ? 'TEMPLATE' : target.nodeName) as keyof HTMLElementTagNameMap);
this.t = target.tagName !== 'TEMPLATE' ? target : (target as HTMLTemplateElement).content;
this.c(html);
}
@@ -674,7 +675,7 @@ export class HtmlTag {
h(html: string) {
this.e.innerHTML = html;
- this.n = Array.from(this.e.nodeName == 'TEMPLATE' ? (this.e as HTMLTemplateElement).content.childNodes : this.e.childNodes);
+ this.n = Array.from(this.e.nodeName === 'TEMPLATE' ? (this.e as HTMLTemplateElement).content.childNodes : this.e.childNodes);
}
i(anchor) {
diff --git a/test/runtime/samples/template/main.svelte b/test/runtime/samples/template/main.svelte
index 502452250e..1fb0d65f47 100644
--- a/test/runtime/samples/template/main.svelte
+++ b/test/runtime/samples/template/main.svelte
@@ -2,4 +2,4 @@
foo
123
-1{@html 'B'}1
+1{@html 'B'}1
\ No newline at end of file