Running this code:
import { parseHTML } from "linkedom";
const { document, MutationObserver } = parseHTML(
"<!doctype html><html><head></head><body>",
);
let mo = new MutationObserver((records) => {
let { nodeName } = records[0].target;
console.assert(nodeName === "BODY", `Expected BODY, got ${nodeName}.`);
});
mo.observe(document, { subtree: true, childList: true });
document.body.appendChild(document.createTextNode(""));
results in this error:
Assertion failed: Expected BODY, got #document.
If I'm reading it correctly, it looks like the target for a mutation is always reported as the node passed to observe (at least for childList) which is incorrect; for the childList MutationRecord type, the target should be the parentNode of the inserted/removed node(s).