Skip to content

Commit

Permalink
Allow setting metadata on child list
Browse files Browse the repository at this point in the history
  • Loading branch information
plexus committed Aug 6, 2024
1 parent 65a6cf7 commit a3d8c7c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
- Add `defprop`, for CSS custom properties (aka variables)
- Add `defutil`, for standalone utility classes
- Add `import-tokens!`, for importing W3C design token JSON files as properties (as per `defprop`)
- Allow setting metadata on a child list, useful for reagent/react keys

## Fixed

- Fix `defined-garden`
- Use of `defrules` in pure-cljs namespaces
- Fix implementation of ILookup on cljs

# 1.12.107 (2023-09-27 / 2444e34)

Expand Down
13 changes: 8 additions & 5 deletions src/lambdaisland/ornament.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,8 @@
"Expand an ornament component being called directly with child elements, without
custom render function."
[tag css-class children extra-attrs]
(let [[tag attrs children :as result]
(let [child-meta (meta children)
[tag attrs children :as result]
(if (sequential? children)
(as-> children $
(if (= :<> (first $)) (next $) $)
Expand All @@ -441,7 +442,10 @@
(merge-attrs (meta children) extra-attrs)
css-class)]
(if (vector? $) (list $) $))))
[tag (attr-add-class extra-attrs css-class) children])]
[tag (attr-add-class extra-attrs css-class) children])
result (if child-meta
(with-meta result child-meta)
result)]
(if (= :<> (first children))
(recur tag nil children attrs)
result)))
Expand Down Expand Up @@ -832,9 +836,8 @@
(lvalue [_] (str "--" (name prop-name)))
(rvalue [_] (str "var(--" (name prop-name) ")"))
ILookup
(-valAt [this kw] (when (= :default kw) default))
(-valAt [this kw fallback] (if (= :default kw) default fallback))
)
(-lookup [this kw] (when (= :default kw) default))
(-lookup [this kw fallback] (if (= :default kw) default fallback)))
{:type ::prop})))

#?(:clj
Expand Down

0 comments on commit a3d8c7c

Please sign in to comment.