Skip init function if stylesheet not found

Instead of throwing an error about a member not being defined or accessed on NULL.
This commit is contained in:
Chauncey McAskill
2021-04-09 15:23:45 -04:00
committed by GitHub
parent b62385c4e0
commit 0d42f65ff6

View File

@@ -10,12 +10,16 @@ const app = new modular({
window.onload = (event) => {
const $style = document.getElementById('main-css');
if ($style.isLoaded) {
init();
} else {
$style.addEventListener('load', (event) => {
if ($style) {
if ($style.isLoaded) {
init();
});
} else {
$style.addEventListener('load', (event) => {
init();
});
}
} else {
console.warn('The "main-css" stylesheet not found');
}
};