From db3abef93a123acbc61ed90bd91ec0b336f00b38 Mon Sep 17 00:00:00 2001 From: sukuwc Date: Mon, 26 Jan 2026 17:37:40 +0100 Subject: [PATCH] Fix null element access in requestAnimationFrame callbacks Add null check for element inside requestAnimationFrame callback in MoltenPushButton and MoltenPushButtonDropdown. The element can become null after await tick() if the component is destroyed during the async operation, causing "Cannot read properties of null" errors. Co-Authored-By: Claude Opus 4.5 --- src/lib/MoltenPushButton.svelte | 4 +++- src/lib/MoltenPushButtonDropdown.svelte | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/MoltenPushButton.svelte b/src/lib/MoltenPushButton.svelte index e3079d7..9ad1584 100644 --- a/src/lib/MoltenPushButton.svelte +++ b/src/lib/MoltenPushButton.svelte @@ -25,7 +25,9 @@ if (element) { await tick(); requestAnimationFrame(() => { - width = element.offsetWidth; + if (element) { + width = element.offsetWidth; + } }); } } diff --git a/src/lib/MoltenPushButtonDropdown.svelte b/src/lib/MoltenPushButtonDropdown.svelte index 7593e31..7e22a7f 100644 --- a/src/lib/MoltenPushButtonDropdown.svelte +++ b/src/lib/MoltenPushButtonDropdown.svelte @@ -17,7 +17,9 @@ if (element) { await tick(); requestAnimationFrame(() => { - width = element.offsetWidth; + if (element) { + width = element.offsetWidth; + } }); } }