Fix get-content-from-element

This commit is contained in:
bom 2023-10-06 11:57:15 +02:00
parent 966ecf1009
commit f147947558

View file

@ -22,21 +22,6 @@
(s/def ::optional boolean?) (s/def ::optional boolean?)
(def dom-function-parameter (s/keys :opt-un [::deserializer ::optional])) (def dom-function-parameter (s/keys :opt-un [::deserializer ::optional]))
(defn-spec get-content-from-element js-object? (defn-spec get-content-from-element js-object?
[name string?
& {:keys [deserializer optional]
:or {deserializer nil optional false}} dom-function-parameter]
(let [content (-> (get-element-by-id name)
(.-value))]
(cond
(and optional (some? deserializer))
(when-not (st/blank? content)
(apply deserializer [content]))
(and (false? optional) (some? deserializer))
(apply deserializer [content])
:else
content)))
(defn-spec get-content-from-element-2 js-object?
[name string? [name string?
& {:keys [deserializer optional] & {:keys [deserializer optional]
:or {deserializer nil optional false}} dom-function-parameter] :or {deserializer nil optional false}} dom-function-parameter]