wv-element% coding
This commit is contained in:
@@ -82,6 +82,7 @@
|
||||
webview-remove-class!
|
||||
webview-set-style!
|
||||
webview-unset-style!
|
||||
webview-get-style
|
||||
|
||||
webview-set-attr!
|
||||
webview-attr
|
||||
@@ -741,6 +742,39 @@
|
||||
)
|
||||
)
|
||||
|
||||
(define/contract (webview-get-style wv selector styles)
|
||||
(-> wv? (or/c symbol? string?) (or/c symbol? list-of-symbol?) (or/c list? hash?))
|
||||
(let ((sel (if (symbol? selector)
|
||||
(format "#~a" selector)
|
||||
selector))
|
||||
(cl (mk-js-array (if (symbol? styles)
|
||||
(list styles)
|
||||
styles)))
|
||||
)
|
||||
(let ((r (webview-call-js wv
|
||||
(with-selector sel
|
||||
(format
|
||||
(js-code
|
||||
"function(id, el) {"
|
||||
" let cl = ~a;"
|
||||
" let r = {};"
|
||||
" cl.forEach(function(st) {"
|
||||
" let stl = window.getComputedStyle(el);"
|
||||
" r[st] = stl[st];"
|
||||
" });"
|
||||
" return { id: id, style: r };"
|
||||
"}") cl))
|
||||
)))
|
||||
(let ((h (hash-ref r 'with-ids)))
|
||||
(let ((l (map (λ (e) (cons (string->symbol (hash-ref e 'id)) (hash-ref e 'style))) h)))
|
||||
(if (symbol? selector)
|
||||
(cdr (car l))
|
||||
l)))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(define/contract (webview-unset-style! wv selector style-entries)
|
||||
(-> wv? (or/c symbol? string?) (or/c symbol? list-of-symbol?) hash?)
|
||||
(let ((sel (if (symbol? selector)
|
||||
|
||||
Reference in New Issue
Block a user