WebReflection / linkedom

A triple-linked lists based DOM implementation.
https://webreflection.medium.com/linkedom-a-jsdom-alternative-53dd8f699311
ISC License
1.66k stars 80 forks source link

null textContent value for DocumentFragment #231

Open davecardwell opened 11 months ago

davecardwell commented 11 months ago

The .textContent attribute of a DocumentFragment—such as the one returned by a <template>’s .content attribute—is null.

import { parseHTML } from "linkedom";

const { document } = parseHTML("");

const template = document.createElement("template");
template.innerHTML = "foo <span>bar</span>";

// in linkedom this is "foo bar", in browsers it’s an empty string
console.log(template.innerText);

const documentFragment = template.content;

// in linkedom this is null, in browsers it’s "foo bar"
console.log(documentFragment.textContent);