From 5393174e2b3ccce36b1d058b7c00ca3ac27d6184 Mon Sep 17 00:00:00 2001 From: Martin Trapp <94928215+martrapp@users.noreply.github.com> Date: Sun, 18 Aug 2024 23:04:32 +0200 Subject: [PATCH] fix race condition (#169) --- .changeset/seven-buttons-swim.md | 5 +++++ components/loading-indicator.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/seven-buttons-swim.md diff --git a/.changeset/seven-buttons-swim.md b/.changeset/seven-buttons-swim.md new file mode 100644 index 0000000..c8632f5 --- /dev/null +++ b/.changeset/seven-buttons-swim.md @@ -0,0 +1,5 @@ +--- +'astro-vtbot': patch +--- + +LoadingIndicator: Increases robustness of indicator creation. diff --git a/components/loading-indicator.ts b/components/loading-indicator.ts index 6a24748..b27c928 100644 --- a/components/loading-indicator.ts +++ b/components/loading-indicator.ts @@ -91,5 +91,5 @@ export async function vtbotLoadingIndicator(options: Options) { div.id = 'vtbot-loading-indicator'; div.appendChild(img!); - document.body.appendChild(div); + document.getElementById('vtbot-loading-indicator') || document.body.appendChild(div); }