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:
@@ -51,8 +51,9 @@ function createMarioDay(container) {
|
||||
container.appendChild(wrapper);
|
||||
|
||||
// Periodically throw out an 8-bit coin
|
||||
setInterval(() => {
|
||||
if (!document.querySelector('.marioday-container')) return;
|
||||
const intervalId = setInterval(() => {
|
||||
if (!document.body.contains(container)) { clearInterval(intervalId); return; }
|
||||
if (container.style.display === 'none') return;
|
||||
const coin = document.createElement('div');
|
||||
coin.className = 'mario-coin';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user