From a66c53ea38e1c0246b944dc285fbe88a0c5ff68a Mon Sep 17 00:00:00 2001 From: Pip Date: Wed, 22 Feb 2023 16:07:23 +0000 Subject: [PATCH] fix: check that turnstile was loaded before calling remove during ondestroy --- projects/ngx-turnstile/src/lib/ngx-turnstile.component.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/projects/ngx-turnstile/src/lib/ngx-turnstile.component.ts b/projects/ngx-turnstile/src/lib/ngx-turnstile.component.ts index d650c49..2ea17d1 100644 --- a/projects/ngx-turnstile/src/lib/ngx-turnstile.component.ts +++ b/projects/ngx-turnstile/src/lib/ngx-turnstile.component.ts @@ -102,6 +102,8 @@ export class NgxTurnstileComponent implements AfterViewInit, OnDestroy { } public ngOnDestroy(): void { - window.turnstile.remove(this.widgetId); + if (this.widgetId) { + window.turnstile.remove(this.widgetId); + } } }