From 5f69ea5ead5d80bf1ba7cfb0c5dd511400f0adfd Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Fri, 29 May 2026 15:15:02 +0200 Subject: [PATCH] fix: remove injected js-dos CSS/script on Play unmount to prevent style leaking into other pages --- frontend/src/pages/Play.svelte | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/frontend/src/pages/Play.svelte b/frontend/src/pages/Play.svelte index ae2117a..5604b66 100644 --- a/frontend/src/pages/Play.svelte +++ b/frontend/src/pages/Play.svelte @@ -17,6 +17,8 @@ let dosContainer; let dosCI = null; + let injectedLink = null; + let injectedScript = null; async function load() { loading = true; @@ -44,6 +46,7 @@ link.rel = "stylesheet"; link.href = "https://v8.js-dos.com/latest/js-dos.css"; document.head.appendChild(link); + injectedLink = link; // Load js-dos script from CDN if (!window.Dos) { @@ -54,6 +57,7 @@ s.onload = resolve; s.onerror = reject; document.head.appendChild(s); + injectedScript = s; }); } catch { error = "Failed to load emulator. Check your internet connection."; @@ -109,6 +113,15 @@ if (dosContainer) { dosContainer.innerHTML = ""; } + // Remove injected js-dos CSS so it doesn't corrupt other pages + if (injectedLink && injectedLink.parentNode) { + injectedLink.parentNode.removeChild(injectedLink); + injectedLink = null; + } + if (injectedScript && injectedScript.parentNode) { + injectedScript.parentNode.removeChild(injectedScript); + injectedScript = null; + } }; });