From 19bbeba75bf90ed24215a7324f88d56df6c940aa Mon Sep 17 00:00:00 2001 From: ghiscoding Date: Mon, 29 Jul 2024 20:11:49 -0400 Subject: [PATCH] fix: make sure `replaceWith()` exists before using it - `replaceWith` doesn't seem to be supported in the Salesforce environment, we can simply add checks to make sure it is a function that exists before trying to call the function --- package/src/scripts/destroy.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/src/scripts/destroy.ts b/package/src/scripts/destroy.ts index 1467a70c..7f30847d 100644 --- a/package/src/scripts/destroy.ts +++ b/package/src/scripts/destroy.ts @@ -6,10 +6,10 @@ const destroy = (self: VanillaCalendar) => { if (self.input) { self.HTMLElement?.parentElement?.removeChild(self.HTMLElement); - self.HTMLInputElement?.replaceWith(self.HTMLOriginalElement); + self.HTMLInputElement?.replaceWith?.(self.HTMLOriginalElement); self.HTMLInputElement = undefined; } else { - self.HTMLElement?.replaceWith(self.HTMLOriginalElement); + self.HTMLElement?.replaceWith?.(self.HTMLOriginalElement); } self.HTMLElement = self.HTMLOriginalElement;