Skip to content

Commit

Permalink
final robustification
Browse files Browse the repository at this point in the history
  • Loading branch information
albertkimjunior committed Jul 4, 2024
1 parent 17f0cd5 commit 9e82031
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion docs/v1/stars.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@ function updateStars() {
});
}

function addNewEventListeners() {
setTimeout(() => {
document.querySelectorAll('li, a').forEach(element => {
element.addEventListener('click', updateStars);
});
}, 100);
}

window.addEventListener('load', function() {
updateStars();
const observer = new MutationObserver(updateStars);
const observer = new MutationObserver(addNewEventListeners);
observer.observe(document.body, { childList: true, subtree: true });
});

0 comments on commit 9e82031

Please sign in to comment.