From 65f51e16aa8f7c070ab5ed5f2bd4f1c034a5659a Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Tue, 21 Jan 2025 10:51:55 +0100 Subject: [PATCH] fix(platform-browser): clear renderer cache during HMR when using async animations (#59644) Fixes that the async animations renderer didn't have the logic to clean up its style cache during HMR. This is identical to #59393. Fixes #59640. PR Close #59644 --- .../animations/async/src/async_animation_renderer.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/platform-browser/animations/async/src/async_animation_renderer.ts b/packages/platform-browser/animations/async/src/async_animation_renderer.ts index 4045f29b71b..c5d172513f8 100644 --- a/packages/platform-browser/animations/async/src/async_animation_renderer.ts +++ b/packages/platform-browser/animations/async/src/async_animation_renderer.ts @@ -167,6 +167,16 @@ export class AsyncAnimationRendererFactory implements OnDestroy, RendererFactory whenRenderingDone?(): Promise { return this.delegate.whenRenderingDone?.() ?? Promise.resolve(); } + + /** + * Used during HMR to clear any cached data about a component. + * @param componentId ID of the component that is being replaced. + */ + protected componentReplaced(componentId: string) { + // Flush the engine since the renderer destruction waits for animations to be done. + this._engine?.flush(); + (this.delegate as {componentReplaced?: (id: string) => void}).componentReplaced?.(componentId); + } } /**