Add checks for container presence in animation functions to prevent errors when elements are removed from the DOM [skip ci]

This commit is contained in:
CodeDevMLH
2026-02-27 04:07:29 +01:00
parent 3c1bd01373
commit bd8088c52b
10 changed files with 20 additions and 15 deletions

View File

@@ -56,9 +56,9 @@ function createOscar(container) {
container.appendChild(carpet);
container.appendChild(spotlights);
// Paparazzi flashes with randomized intervals
function flashLoop() {
if (!document.querySelector('.oscar-container')) {
if (!document.body.contains(container)) return; // Kill the loop if container is removed
if (container.style.display === 'none') {
setTimeout(flashLoop, 1000); // Check again later if hidden
return;
}