Skip to content

Commit c7933dc

Browse files
committed
HTMLTemplateElement innerHTML output bugfix (cjs, esm)
--browser result-- const f = document.createDocumentFragment(); const d = document.createElement('div') d.innerHTML='<a>aaa</a>'; f.append(d); const t = document.createElement('template'); t.content.append(f); console.log(t.innerHTML); // '<div><a>aaa</a></div>' console.log(t.innerText); //'' --linkedom-- console.log(t.innerHTML); // '' console.log(t.innerText); //'' After appending the child element to the HTML Template Element's content If you do innerHTML, it is normal to output the contents of the child element, but it is not output in linkedom. bugfix
1 parent dfc2fa8 commit c7933dc

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

cjs/html/template-element.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const {registerHTMLClass} = require('../shared/register-html-class.js');
55

66
const {HTMLElement} = require('./element.js');
77

8+
import {getInnerHtml} from '../mixin/inner-html.js'
9+
810
const tagName = 'template';
911

1012
/**
@@ -17,6 +19,10 @@ class HTMLTemplateElement extends HTMLElement {
1719
(this[CONTENT] = content)[PRIVATE] = this;
1820
}
1921

22+
get innerHTML() {
23+
return getInnerHtml(this.content);
24+
}
25+
2026
get content() {
2127
if (this.hasChildNodes() && !this[CONTENT].hasChildNodes()) {
2228
for (const node of this.childNodes)

esm/html/template-element.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import {registerHTMLClass} from '../shared/register-html-class.js';
44

55
import {HTMLElement} from './element.js';
66

7+
import {getInnerHtml} from '../mixin/inner-html.js'
8+
79
const tagName = 'template';
810

911
/**
@@ -16,6 +18,10 @@ class HTMLTemplateElement extends HTMLElement {
1618
(this[CONTENT] = content)[PRIVATE] = this;
1719
}
1820

21+
get innerHTML() {
22+
return getInnerHtml(this.content);
23+
}
24+
1925
get content() {
2026
if (this.hasChildNodes() && !this[CONTENT].hasChildNodes()) {
2127
for (const node of this.childNodes)

0 commit comments

Comments
 (0)