From 9185cee7c93f294a9ea1b5b0df3c2c81c16e1216 Mon Sep 17 00:00:00 2001 From: Joris Date: Mon, 10 Mar 2025 08:53:35 +0100 Subject: Call onmount when the element is on the page Otherwise, using the element to call focus for example would not work. --- src/rx.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/rx.ts b/src/rx.ts index c46c2f5..edd28bf 100644 --- a/src/rx.ts +++ b/src/rx.ts @@ -384,7 +384,8 @@ function appendChild(state: State, element: Element, child: Html, lastAdded?: No appendNode(element, childElement, lastAdded) if (onmount !== undefined) { - onmount(childElement) + // Wait for the element to be on the page + window.setTimeout(() => onmount(childElement), 0) } return { -- cgit v1.2.3