You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix template element parsing and innerHTML handling
- Fix template children being parsed into element.childNodes instead of template.content during parseHTML()
- Add special handling in parse-from-string.js to redirect template children to content DocumentFragment
- Implement proper template.innerHTML getter/setter to access content instead of direct children
- Add template.toString() method following TextElement pattern to include content in serialization
- Ensure template element follows HTML spec where innerHTML always references template.content
- Add null safety checks in parsing logic to prevent errors during template processing
The template element now correctly:
- Parses children into content during HTML parsing
- Returns content innerHTML when accessing template.innerHTML
- Maintains separation between direct children and content
- Serializes with content included in toString()
--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); //''
assert(template.innerHTML,'<div><a>child element innerHTML</a></div>','template.innerHTML The template maintains internal HTML even with additional children');
0 commit comments