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,38 +89,46 @@
(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))
(format (set! js-type (webview-call-js wv
(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 === null) {\n" " if (a == -1) {\n"
" return false;\n" " return a;\n"
" } else {\n" " else { \n"
" return a;\n" " if (a === null) {\n"
" return false;\n"
" } else {\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%) ((eq? type 'time) wv-input/time%)
((eq? type 'time) wv-input/time%) ((eq? type 'datetime-local) wv-input/datetime%)
((eq? type 'datetime-local) wv-input/datetime%) ((eq? type 'range) wv-input/range%)
((eq? type 'range) wv-input/range%) ((eq? type 'number) wv-input/number%)
((eq? type 'number) wv-input/number%) ((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
(else wv-element%) (err-webview "Element with id '~a' not found"
))) id)
(set! elem (new cl [window this] [element-id id])) wv-element%))
(hash-set! element-hash id elem)) (else wv-element%)
) )))
(set! elem (new cl [window this] [element-id id]))
(hash-set! element-hash id elem))
))
elem elem
) )
) )