linkedom icon indicating copy to clipboard operation
linkedom copied to clipboard

null textContent value for DocumentFragment

Open davecardwell opened this issue 2 years ago • 0 comments

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);

davecardwell avatar Oct 20 '23 21:10 davecardwell