diff options
| author | Asko Nõmm <asko@nmm.ee> | 2025-09-26 15:15:50 +0300 |
|---|---|---|
| committer | Asko Nõmm <asko@nmm.ee> | 2025-09-26 15:15:50 +0300 |
| commit | 1a99176287d085b6784cb0113f415d0b0dddff6e (patch) | |
| tree | 9bd469eb4642cf19f447597d22e8a3bd8bb1a960 /src/dompa | |
| parent | ea8dea2dd173c2e899640acae7d27e7e95b585f7 (diff) | |
Use `cond->` instead of `merge`
Diffstat (limited to 'src/dompa')
| -rw-r--r-- | src/dompa/coordinates.cljc | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/dompa/coordinates.cljc b/src/dompa/coordinates.cljc index 4f9a436..2d7e29d 100644 --- a/src/dompa/coordinates.cljc +++ b/src/dompa/coordinates.cljc @@ -257,15 +257,12 @@ (defn- construct-node [node-html node-children] - (let [node-name (html-str->node-name node-html)] - (merge - {:node/name node-name} - (when (= node-name :dompa/text) - {:node/value node-html}) - (when-let [attrs (html-str->node-attrs node-html)] - {:node/attrs attrs}) - (when node-children - {:node/children node-children})))) + (let [node-name (html-str->node-name node-html) + node-attrs (html-str->node-attrs node-html)] + (cond-> {:node/name node-name} + (= node-name :dompa/text) (assoc :node/value node-html) + (not (nil? node-attrs)) (assoc :node/attrs node-attrs) + (not (nil? node-children)) (assoc :node/children node-children)))) (defn ->nodes "Transform given `html` according to given `coordinates` into |
