/** * Minimal DOM shim so the Statum module files can be loaded under QuickJS. * * The modules are IIFEs; statum-core.js attaches `window.statum` and calls * autoInit() at load time. autoInit() only needs `document.readyState` (we * report 'loading' so it registers a DOMContentLoaded listener instead of * running), and the rest of the boot path is never exercised by the markdown * tests. * * Set `__STATUM_TEST__` before loading statum-markdown.js to expose * `statum._testMarkdown` (see the comment at the bottom of that module). */ export function installShim() { var listeners = {}; function makeElement() { return { tagName: 'DIV', style: {}, dataset: {}, attributes: [], children: [], setAttribute: function () {}, removeAttribute: function () {}, hasAttribute: function () { return false; }, getAttribute: function () { return null; }, addEventListener: function () {}, removeEventListener: function () {}, appendChild: function (c) { return c; }, removeChild: function (c) { return c; }, replaceWith: function () {}, querySelectorAll: function () { return []; }, querySelector: function () { return null; }, classList: { add: function () {}, remove: function () {}, contains: function () { return false; } }, contains: function () { return false; } }; } globalThis.console = { log: function () {}, warn: function () {}, error: function () {}, info: function () {}, debug: function () {} }; globalThis.document = { readyState: 'loading', cookie: '', head: makeElement(), body: makeElement(), documentElement: makeElement(), addEventListener: function (t, f) { (listeners[t] = listeners[t] || []).push(f); }, removeEventListener: function () {}, getElementById: function () { return null; }, querySelectorAll: function () { return []; }, querySelector: function () { return null; }, createElement: function () { return makeElement(); }, createTextNode: function (t) { return { nodeType: 3, textContent: t }; } }; globalThis.window = globalThis; globalThis.location = { href: 'http://localhost/', protocol: 'http:', addEventListener: function () {} }; globalThis.navigator = { userAgent: 'qjs' }; globalThis.addEventListener = function (t, f) { (listeners[t] = listeners[t] || []).push(f); }; globalThis.removeEventListener = function () {}; globalThis.__STATUM_TEST__ = true; }