(function () { if (window.__miradorSpaceFixInitialized) return; window.__miradorSpaceFixInitialized = true; const observer = new MutationObserver((mutations) => { const elements = document.querySelectorAll( ".mirador-third-party-html:not([data-fixed])" ); elements.forEach((el) => { // Create a TreeWalker to find all text nodes inside this container const walker = document.createTreeWalker( el, NodeFilter.SHOW_TEXT, null, false ); let node; while ((node = walker.nextNode())) { // Replace both non-breaking space characters and entity text if present if (node.nodeValue) { node.nodeValue = node.nodeValue .replace(/\u00A0/g, " ") .replace(/ /g, " "); } } el.setAttribute("data-fixed", "true"); }); }); observer.observe(document.body, { childList: true, subtree: true, }); })();