From dfe112dd5119258f0d9acbc637a43c301ddedcce Mon Sep 17 00:00:00 2001 From: Hans Dijkema Date: Wed, 15 Apr 2026 23:32:13 +0200 Subject: [PATCH] implement wait-for-element (to be accessable in DOM) --- wv-window.rkt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/wv-window.rkt b/wv-window.rkt index 2efb2f8..048a739 100644 --- a/wv-window.rkt +++ b/wv-window.rkt @@ -132,10 +132,22 @@ (set! elem (new cl [window this] [element-id id])) (hash-set! element-hash id elem)) ) - (displayln (format "element ~a: ~a" id elem)) + ;(displayln (format "element ~a: ~a" id elem)) elem ) ) + + (define (wait-for-element id) + (webview-call-js wv (string-append + (format "{ let el = document.getElementById('~a');" id) + " while (el === null) { " + " window.setTimeout(function (){ }, 0);" + (format " el = document.getElementById('~a');" id) + " }" + " return true;" + "}") + ) + ) (define (connect! id type event callback) (let ((elem (element id type)))