Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

not working HTMLTemplateElement Content append after innerHTML result empty string

未关闭
#313 3 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
42/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
冷清
技术栈
typescript
领域
web-dev

调研方向

从此 issue 中的 TypeScript 复现开始:将一个 DocumentFragment 附加到 template.content,然后比较 template.innerHTML 与 template.content.children。跟踪 HTMLTemplateElement 的序列化路径,并添加覆盖,表明附加的内容会出现在 innerHTML 中,同时保留报告的 children 结果。

由索引模型根据 Issue 内容生成。

描述

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

主要语言
HTML
星标
2.1k
派生
104
PR 合并指标
30 天内没有已合并 PR

环境准备

我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

WebReflection/linkedom 的其他 Issue

查看 WebReflection/linkedom 的全部 Issue

相似的 Issue

更多 Web Dev Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。