From c5d8f81eb15a9af8457b60758bb31c156f90857f Mon Sep 17 00:00:00 2001 From: DerZyklop Date: Mon, 9 Dec 2019 19:35:25 +0100 Subject: [PATCH] Fixes MrFrankel/ngx-popper#126 Performance improvement: Added condition to `clearTimeout(...)`, so it only runs if a timeout was started. --- src/popper-directive.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/popper-directive.ts b/src/popper-directive.ts index da601fe..2467f1d 100644 --- a/src/popper-directive.ts +++ b/src/popper-directive.ts @@ -235,8 +235,8 @@ export class PopperController implements OnInit, OnDestroy, OnChanges { this.subscriptions.length = 0; this.clearEventListeners(); this.clearGlobalEventListeners(); - clearTimeout(this.scheduledShowTimeout); - clearTimeout(this.scheduledHideTimeout); + if (this.scheduledShowTimeout !== undefined) clearTimeout(this.scheduledShowTimeout); + if (this.scheduledHideTimeout !== undefined) clearTimeout(this.scheduledHideTimeout); this.popperContent && this.popperContent.clean(); }