webview-get-style debugging
This commit is contained in:
+30
-27
@@ -1026,40 +1026,43 @@
|
||||
; styles)))
|
||||
)
|
||||
(let* ((js-code (with-selector sel
|
||||
(λ (id el)
|
||||
(let ((cl (eval cl))
|
||||
(r '()))
|
||||
(send cl forEach
|
||||
(λ (st)
|
||||
(send console log st)
|
||||
(let ((stl (send window getComputedStyle el)))
|
||||
(set! (js-ref r st) (js-ref stl st)))))
|
||||
(send console log r)
|
||||
(return (list (list 'id id)
|
||||
(list 'style (send Object entries r))))))
|
||||
(λ (id el)
|
||||
(let ((cl (eval cl))
|
||||
(r '()))
|
||||
(send cl forEach
|
||||
(λ (st)
|
||||
(send console log st)
|
||||
(let ((stl (send window getComputedStyle el)))
|
||||
(set! (js-ref r st) (js-ref stl st)))))
|
||||
(send console log r)
|
||||
(return (list (list 'id id)
|
||||
(list 'style (send Object entries r))))))
|
||||
))
|
||||
(r (webview-call-js wv js-code))
|
||||
)
|
||||
; (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))
|
||||
; )))
|
||||
; (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))
|
||||
; )))
|
||||
(displayln (format "~a: ~a" r js-code))
|
||||
(if (eq? r #f)
|
||||
#f
|
||||
(let ((h (hash-ref r 'with-ids)))
|
||||
(let ((l (map (λ (e)
|
||||
(cons
|
||||
(string->symbol (hash-ref e 'id))
|
||||
(hash-ref e 'style))) h)))
|
||||
(let ((l (map (λ (e)
|
||||
(let ((id-rec (car e))
|
||||
(style-rec (cadr e)))
|
||||
(cons (string->symbol (cadr id-rec))
|
||||
(make-hash (map (λ (e) (cons (car e) (cadr e))) (cadr style-rec)))
|
||||
)
|
||||
)) h)))
|
||||
(if (symbol? selector)
|
||||
(cdr (car l))
|
||||
l))))
|
||||
|
||||
Reference in New Issue
Block a user