diff --git a/src/internal/plugins/controllers/alert-flash-content.ts b/src/internal/plugins/controllers/alert-flash-content.ts index 9ab0dd47fc3..656854115c6 100644 --- a/src/internal/plugins/controllers/alert-flash-content.ts +++ b/src/internal/plugins/controllers/alert-flash-content.ts @@ -83,7 +83,9 @@ export class AlertFlashContentController { onContentRegistered = (listener: AlertFlashContentRegistrationListener) => { const cleanup = listener(this.#provider); this.#listeners.push(listener); - this.#cleanups.set(listener, cleanup ?? null); + if (cleanup) { + this.#cleanups.set(listener, cleanup); + } return () => { this.#cleanups.get(listener)?.();