fix: update instanceof check

web-rdp-cloud-fixes
Parkreiner 10 months ago
parent 5ec1b207d1
commit c7a4fced4c

@ -359,12 +359,11 @@ function setupAlwaysOnStyles() {
function hideFormForInitialSubmission() { function hideFormForInitialSubmission() {
const styleId = "coder-patch--styles-initial-submission"; const styleId = "coder-patch--styles-initial-submission";
const existingContainer = document.querySelector("#" + styleId);
if (existingContainer) {
return;
}
const styleContainer = document.createElement("style"); /** @type {HTMLStyleElement | null} */
let styleContainer = document.querySelector("#" + styleId);
if (!styleContainer) {
styleContainer = document.createElement("style");
styleContainer.id = styleId; styleContainer.id = styleId;
styleContainer.innerHTML = ` styleContainer.innerHTML = `
/* /*
@ -373,8 +372,8 @@ function hideFormForInitialSubmission() {
*/ */
:root { :root {
/* /*
Can be 0 or 1. Start off invisible to avoid risks of UI flickering, but Can be 0 or 1. Start off invisible to avoid risks of UI flickering,
the rest of the function should be in charge of making the form but the rest of the function should be in charge of making the form
container visible again if something goes wrong during setup. container visible again if something goes wrong during setup.
*/ */
--coder-opacity-multiplier: 1; --coder-opacity-multiplier: 1;
@ -387,13 +386,14 @@ function hideFormForInitialSubmission() {
`; `;
document.head.appendChild(styleContainer); document.head.appendChild(styleContainer);
}
// The root node being undefined should be physically impossible (if it's // The root node being undefined should be physically impossible (if it's
// undefined, the browser itself is busted), but we need to do a type check // undefined, the browser itself is busted), but we need to do a type check
// here so that the rest of the function doesn't need to do type checks over // here so that the rest of the function doesn't need to do type checks over
// and over. // and over.
const rootNode = document.querySelector(":root"); const rootNode = document.querySelector(":root");
if (!(rootNode instanceof HTMLElement)) { if (!(rootNode instanceof HTMLHtmlElement)) {
styleContainer.innerHTML = ""; styleContainer.innerHTML = "";
return; return;
} }

Loading…
Cancel
Save