Skip to content

Commit c15fec6

Browse files
committed
Fix requestAnimationFrame teardown errors by automatically canceling animations in clearAnimations()
1 parent 58b2301 commit c15fec6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/mocks/web-animations-api/elementAnimations.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,12 @@ export function getAllAnimations() {
2828
}
2929

3030
export function clearAnimations() {
31+
// Cancel all running animations to prevent requestAnimationFrame errors during teardown
32+
const allAnimations = getAllAnimations();
33+
allAnimations.forEach((animation) => {
34+
// Cancel the animation properly - this stops the requestAnimationFrame loop
35+
animation.cancel();
36+
});
37+
3138
elementAnimations.clear();
3239
}

0 commit comments

Comments
 (0)