WebReflection / WebReflection/linkedom

not working HTMLTemplateElement Content append after innerHTML result empty string

Open
#313 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
2.1k
Forks
104
PR merge metrics
No merged PRs in 30d

Description

PR: https://github.com/WebReflection/linkedom/pull/315

const data: DocumentFragment = ...
const template = window.document.createElement('template') as HTMLTemplateElement;
template.content.append(data);

 console.log('innerHTML:', template.innerHTML, 'children:',Array.from(template.content.children));  // innerHTML emptyString

not working..

innerHTML output is empty string

 console.log('innerHTML:', template.innerHTML, 'children:',Array.from(template.content.children));

--log result--
innerHTML: children: [
<ref *1> HTMLStyleElement {
ownerDocument: HTMLDocument {
ownerDocument: null,
localName: '#document',
nodeType: 9,
parentNode: null,
[Symbol(next)]: [DocumentType],
[Symbol(prev)]: null,
[Symbol(private)]: null,
[Symbol(end)]: [Object],
[Symbol(CustomElements)]: [Object],
[Symbol(MutationObserver)]: [Object],
[Symbol(mime)]: [Object],
[Symbol(doctype)]: [DocumentType],
[Symbol(DOMParser)]: [class DOMParser],
[Symbol(globals)]: null,
[Symbol(image)]: null,
[Symbol(upgrade)]: null,
[Symbol(EventTarget)]: [DOMEventTarget]
},
localName: 'style',
nodeType: 1,
parentNode: DocumentFragment {
ownerDocument: [HTMLDocument],
localName: '#document-fragment',
nodeType: 11,
parentNode: null,
[Symbol(next)]: [Circular *1],
[Symbol(prev)]: null,
[Symbol(private)]: [HTMLTemplateElement],
[Symbol(end)]: [Object]
},
[Symbol(next)]: Attr {
ownerDocument: [HTMLDocument],
localName: 'id',
nodeType: 2,
parentNode: null,
ownerElement: [Circular *1],
name: 'id',
[Symbol(next)]: [Attr],
[Symbol(prev)]: [Circular *1],
[Symbol(value)]: 'KQykvzSaQPUDomNDyYpuZNdcxkWCkvHtGvVujfjH-style',
[Symbol(changed)]: false
},
[Symbol(prev)]: DocumentFragment {
ownerDocument: [HTMLDocument],
localName: '#document-fragment',
nodeType: 11,
parentNode: null,
[Symbol(next)]: [Circular *1],
[Symbol(prev)]: null,
[Symbol(private)]: [HTMLTemplateElement],
[Symbol(end)]: [Object]
},
[Symbol(private)]: null,
[Symbol(end)]: {
nodeType: -1,
ownerDocument: [HTMLDocument],
parentNode: null,
[Symbol(next)]: [HTMLElement],
[Symbol(prev)]: [Attr],
[Symbol(start)]: [Circular *1]
},
...
]

I was thus treated with innerHTML.

  • template.innerHTM; .. template.content

But I think it needs to be fixed

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the TypeScript reproduction in this issue: append a DocumentFragment to template.content, then compare template.innerHTML with template.content.children. Trace the HTMLTemplateElement serialization path and add coverage showing that appended content appears in innerHTML while preserving the reported children result.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.