fix: guard against invalid accesses

Current check does only check for presence of document and assumes the full tree below exists but that is not always the case and can lead to exceptions.
This commit is contained in:
Manuel 2022-07-29 13:23:49 +02:00 committed by GitHub
commit 922bf7e2e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -31,6 +31,6 @@ export const trackModal = (openStore) =>
}); });
modalsOpen.subscribe((openCount) => { modalsOpen.subscribe((openCount) => {
if (typeof document !== "undefined") if (typeof document !== "undefined" && document.body && document.body.classList && typeof document.body.classList.toggle === "function")
document.body.classList.toggle("bx--body--with-modal-open", openCount > 0); document.body.classList.toggle("bx--body--with-modal-open", openCount > 0);
}); });