refactor(core): prevent timeout from applying to non-event animation bindings (#63393)

The 4 second removal timeout was applying in all cases, but it should only actually apply to the situation where the event binding syntax is used for animate.leave. This ensures that's the only case in which it'll apply.

PR Close #63393
This commit is contained in:
Jessica Janiuk 2025-08-26 13:35:31 +02:00 committed by Andrew Kushnir
parent 8e4b7e47f4
commit fa0f11f6e8
2 changed files with 8 additions and 2 deletions

View file

@ -65,6 +65,7 @@ export class ElementRegistry {
const details = this.outElements.get(el) ?? {
classes: null,
animateFn: () => {},
isEventBinding: true,
};
details.animateFn = animateWrapperFn(el, value);
this.outElements.set(el, details);
@ -75,6 +76,7 @@ export class ElementRegistry {
const details = this.outElements.get(el) ?? {
classes: new Set<string>(),
animateFn: (): void => {},
isEventBinding: false,
};
if (typeof value === 'function') {
this.trackResolver(details, value);
@ -109,8 +111,11 @@ export class ElementRegistry {
};
// this timeout is used to ensure elements actually get removed in the case
// that the user forgot to call the remove callback. The timeout is cleared
// in the DOM renderer during the remove child process.
timeoutId = setTimeout(remove, maxAnimationTimeout);
// in the DOM renderer during the remove child process. It only applies
// to the event binding use case.
if (details.isEventBinding) {
timeoutId = setTimeout(remove, maxAnimationTimeout);
}
details.animateFn(remove);
}
}

View file

@ -67,4 +67,5 @@ export interface AnimationDetails {
classes: Set<string> | null;
classFns?: Function[];
animateFn: AnimationRemoveFunction;
isEventBinding: boolean;
}