innerHTmL problems. Not synchronous?

This commit is contained in:
2026-04-15 20:39:22 +02:00
parent 977f25d997
commit ef91a15cb7
2 changed files with 36 additions and 27 deletions

View File

@@ -745,7 +745,8 @@
(if (string? html) (if (string? html)
(let ((r (webview-call-js wv (let ((r (webview-call-js wv
(with-id id el (with-id id el
("el.innerHTML = '~a'; return true;" (esc-quote html)))))) ("el.innerHTML = '~a';
await new Promise(resolve => setTimeout(resolve, 0)); return true;" (esc-quote html))))))
(if r 'oke 'failed)) (if r 'oke 'failed))
(webview-set-innerHTML! wv id (xexpr->string html)) (webview-set-innerHTML! wv id (xexpr->string html))
) )

View File

@@ -89,23 +89,27 @@
(type (if (null? type*) #f (car type*)))) (type (if (null? type*) #f (car type*))))
(when (eq? elem #f) (when (eq? elem #f)
(when (eq? type #f) (when (eq? type #f)
(let ((js-type (webview-call-js wv (let ((js-type -1))
(set! js-type (webview-call-js wv
(format (format
(string-append (string-append
"{ let el = document.getElementById('~a');\n" "{ let el = document.getElementById('~a');\n"
" let a = (el === null) ? null : el.getAttribute('type');\n" " let a = (el === null) ? -1 : el.getAttribute('type');\n"
" if (a == -1) {\n"
" return a;\n"
" else { \n"
" if (a === null) {\n" " if (a === null) {\n"
" return false;\n" " return false;\n"
" } else {\n" " } else {\n"
" return a;\n" " return a;\n"
" }"
" }\n" " }\n"
"}") "}")
id)))) id))))
(set! type (if (eq? js-type #f) (set! type (if (eq? js-type #f)
#f (if (= js-type -1)
(string->symbol (string-downcase js-type)))) 'unknown
) (string->symbol (string-downcase js-type)))))
)
(let ((cl (cond (let ((cl (cond
((eq? type 'text) wv-input/text%) ((eq? type 'text) wv-input/text%)
((eq? type 'date) wv-input/date%) ((eq? type 'date) wv-input/date%)
@@ -116,11 +120,15 @@
((eq? type 'checkbox) wv-input/check%) ((eq? type 'checkbox) wv-input/check%)
((eq? type 'radio) wv-input/radio%) ((eq? type 'radio) wv-input/radio%)
((eq? type 'color) wv-input/color%) ((eq? type 'color) wv-input/color%)
((eq? type 'unknown) (begin
(err-webview "Element with id '~a' not found"
id)
wv-element%))
(else wv-element%) (else wv-element%)
))) )))
(set! elem (new cl [window this] [element-id id])) (set! elem (new cl [window this] [element-id id]))
(hash-set! element-hash id elem)) (hash-set! element-hash id elem))
) ))
elem elem
) )
) )