From 35f5a8f60da974e7022c65fa3efb907cd951ee1d Mon Sep 17 00:00:00 2001 From: Hans Dijkema Date: Mon, 9 Mar 2026 21:06:06 +0100 Subject: [PATCH] wv-element% coding --- private/racket-webview.rkt | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/private/racket-webview.rkt b/private/racket-webview.rkt index 3b2f2d6..5d15336 100644 --- a/private/racket-webview.rkt +++ b/private/racket-webview.rkt @@ -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)