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 dosContainer;
|
||||||
let dosCI = null;
|
let dosCI = null;
|
||||||
|
let injectedLink = null;
|
||||||
|
let injectedScript = null;
|
||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
loading = true;
|
loading = true;
|
||||||
@@ -44,6 +46,7 @@
|
|||||||
link.rel = "stylesheet";
|
link.rel = "stylesheet";
|
||||||
link.href = "https://v8.js-dos.com/latest/js-dos.css";
|
link.href = "https://v8.js-dos.com/latest/js-dos.css";
|
||||||
document.head.appendChild(link);
|
document.head.appendChild(link);
|
||||||
|
injectedLink = link;
|
||||||
|
|
||||||
// Load js-dos script from CDN
|
// Load js-dos script from CDN
|
||||||
if (!window.Dos) {
|
if (!window.Dos) {
|
||||||
@@ -54,6 +57,7 @@
|
|||||||
s.onload = resolve;
|
s.onload = resolve;
|
||||||
s.onerror = reject;
|
s.onerror = reject;
|
||||||
document.head.appendChild(s);
|
document.head.appendChild(s);
|
||||||
|
injectedScript = s;
|
||||||
});
|
});
|
||||||
} catch {
|
} catch {
|
||||||
error = "Failed to load emulator. Check your internet connection.";
|
error = "Failed to load emulator. Check your internet connection.";
|
||||||
@@ -109,6 +113,15 @@
|
|||||||
if (dosContainer) {
|
if (dosContainer) {
|
||||||
dosContainer.innerHTML = "";
|
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>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user