From 94afbc896fd3089897d352fd2352bc9f6c4b643d Mon Sep 17 00:00:00 2001 From: Ahmed Asi <95191621+AchoDev@users.noreply.github.com> Date: Tue, 18 Nov 2025 12:06:54 +0100 Subject: [PATCH 1/3] fix(#14112): changed from using setTimeout to requestAnimationFrame --- .../runtime-dom/src/components/Transition.ts | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/packages/runtime-dom/src/components/Transition.ts b/packages/runtime-dom/src/components/Transition.ts index 9ee9a8e0820..81b67cc3c13 100644 --- a/packages/runtime-dom/src/components/Transition.ts +++ b/packages/runtime-dom/src/components/Transition.ts @@ -378,11 +378,35 @@ function whenTransitionEnds( end() } } - setTimeout(() => { - if (ended < propCount) { - end() + // setTimeout(() => { + // if (ended < propCount) { + // end() + // } + // }, timeout + 1) + + const fallbackTimeout = () => { + let loopStart: number | null = null + const loop = (timeStamp: number) => { + if (!loopStart) { + loopStart = timeStamp + } + + const elapsed = timeStamp - loopStart + if (elapsed >= timeout + 1) { + if (ended < propCount) { + end() + return + } + } + + requestAnimationFrame(loop) } - }, timeout + 1) + + requestAnimationFrame(loop) + } + + fallbackTimeout() + el.addEventListener(endEvent, onEnd) } From 600eb017e5474c48b974b7967db8b8dbdf93e420 Mon Sep 17 00:00:00 2001 From: Ahmed Asi <95191621+AchoDev@users.noreply.github.com> Date: Tue, 18 Nov 2025 12:22:50 +0100 Subject: [PATCH 2/3] fix(#14112): removed old setTimeout --- packages/runtime-dom/src/components/Transition.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/runtime-dom/src/components/Transition.ts b/packages/runtime-dom/src/components/Transition.ts index 81b67cc3c13..a65f7a5a165 100644 --- a/packages/runtime-dom/src/components/Transition.ts +++ b/packages/runtime-dom/src/components/Transition.ts @@ -378,11 +378,6 @@ function whenTransitionEnds( end() } } - // setTimeout(() => { - // if (ended < propCount) { - // end() - // } - // }, timeout + 1) const fallbackTimeout = () => { let loopStart: number | null = null From fd1ec04ae488d726e56656f4f229374cc5394e16 Mon Sep 17 00:00:00 2001 From: Ahmed Asi <95191621+AchoDev@users.noreply.github.com> Date: Tue, 18 Nov 2025 12:31:42 +0100 Subject: [PATCH 3/3] fix(#14113): loop always stops and doesn't run forever now --- .../runtime-dom/src/components/Transition.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/runtime-dom/src/components/Transition.ts b/packages/runtime-dom/src/components/Transition.ts index a65f7a5a165..cf9cc55666c 100644 --- a/packages/runtime-dom/src/components/Transition.ts +++ b/packages/runtime-dom/src/components/Transition.ts @@ -371,6 +371,7 @@ function whenTransitionEnds( let ended = 0 const end = () => { el.removeEventListener(endEvent, onEnd) + cancelFeedback() resolveIfNotStale() } const onEnd = (e: Event) => { @@ -381,7 +382,12 @@ function whenTransitionEnds( const fallbackTimeout = () => { let loopStart: number | null = null + let rafId: number const loop = (timeStamp: number) => { + if (id !== el._endId) { + return + } + if (!loopStart) { loopStart = timeStamp } @@ -390,17 +396,19 @@ function whenTransitionEnds( if (elapsed >= timeout + 1) { if (ended < propCount) { end() - return } + return } - requestAnimationFrame(loop) + rafId = requestAnimationFrame(loop) } - requestAnimationFrame(loop) + rafId = requestAnimationFrame(loop) + + return () => cancelAnimationFrame(rafId) } - fallbackTimeout() + const cancelFeedback = fallbackTimeout() el.addEventListener(endEvent, onEnd) }