HtmlTag::m normalize the case target is a fragment of template

pull/7364/head
lidlanca 4 years ago
parent 10337582c5
commit 9f368bc201

@ -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 <template> 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) {

@ -2,4 +2,4 @@
<div>foo</div>
</template>
<template id="t2">123</template>
<template id="t3">1{@html '<b>B</b>'}1</template>
<template id="t3">1{@html '<b>B</b>'}1</template>
Loading…
Cancel
Save