Adjustment to the request debug view functionality

This commit is contained in:
2026-09-18 16:46:47 -03:00
parent ac817a69d4
commit eed4189a07
20 changed files with 945 additions and 87 deletions

View File

@@ -0,0 +1,25 @@
function createDebugDom() {
const descendants = node => [node, ...node.children.flatMap(descendants)];
const document = { activeElement: null };
function element(tag) {
return {
tag, children: [], attributes: {}, listeners: {}, scrollTop: 0, hidden: false, text: "",
set textContent(value) { this.text = value; this.children = []; },
get textContent() { return this.text; },
append(...nodes) { this.children.push(...nodes); },
setAttribute(key, value) { this.attributes[key] = value; },
getAttribute(key) { return this.attributes[key]; },
addEventListener(name, listener) { this.listeners[name] = listener; },
focus() { document.activeElement = this; },
querySelectorAll(selector) {
return descendants(this).filter(node => node.tag === "details"
&& node.getAttribute("data-request-id") && (!selector.includes("[open]") || node.open));
}
};
}
const panel = element("aside");
Object.assign(document, { getElementById: () => panel, createElement: element, createElementNS: (_, tag) => element(tag) });
return { document, panel, descendants };
}
module.exports = { createDebugDom };