fix: remove injected js-dos CSS/script on Play unmount to prevent style leaking into other pages
Build & Deploy / build-and-deploy (push) Successful in 48s
Build & Deploy / build-and-deploy (push) Successful in 48s
This commit is contained in:
@@ -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;
|
||||
}
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user