PlotDirector/PlotLine/wwwroot/js/writing-embedded-theme.js

3 lines
703 B
JavaScript

// Reuse the surrounding PWA's theme policy; no separate theme settings or persistence.
(()=>{if(parent===window)return;try{const outer=parent.document.documentElement;const sync=()=>{for(const name of ['data-app-theme','data-theme','data-bs-theme']){const value=outer.getAttribute(name);if(value)document.documentElement.setAttribute(name,value);else document.documentElement.removeAttribute(name);}};sync();const observer=new MutationObserver(sync);observer.observe(outer,{attributes:true,attributeFilter:['data-app-theme','data-theme','data-bs-theme']});window.addEventListener('pagehide',()=>observer.disconnect());}catch{/* A foreign embedding page cannot supply trusted appearance state. */}})();