Skip to content

Commit 7c43034

Browse files
committed
Make CSSProps implement print-dup, so they can be AOTd
1 parent 661281f commit 7c43034

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

src/lambdaisland/ornament.cljc

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -838,22 +838,26 @@
838838
(lvalue [p])
839839
(rvalue [p]))
840840

841+
#?(:clj
842+
(deftype CSSProperty [prop-name default]
843+
CSSProp
844+
(lvalue [_] (str "--" (name prop-name)))
845+
(rvalue [_] (str "var(--" (name prop-name) ")"))
846+
gu/ToString
847+
(to-str [this]
848+
(str "--" (name prop-name)))
849+
Object
850+
(toString [_] (str "var(--" (name prop-name) ")"))
851+
clojure.lang.ILookup
852+
(valAt [this kw] (when (= :default kw) default))
853+
(valAt [this kw fallback] (if (= :default kw) default fallback))
854+
clojure.lang.IMeta
855+
(meta [this] {:type ::prop}))
856+
)
857+
841858
(defn css-prop [prop-name default]
842859
#?(:clj
843-
(with-meta
844-
(reify
845-
CSSProp
846-
(lvalue [_] (str "--" (name prop-name)))
847-
(rvalue [_] (str "var(--" (name prop-name) ")"))
848-
gu/ToString
849-
(to-str [this]
850-
(str "--" (name prop-name)))
851-
Object
852-
(toString [_] (str "var(--" (name prop-name) ")"))
853-
clojure.lang.ILookup
854-
(valAt [this kw] (when (= :default kw) default))
855-
(valAt [this kw fallback] (if (= :default kw) default fallback)))
856-
{:type ::prop})
860+
(->CSSProperty prop-name default)
857861
:cljs
858862
(with-meta
859863
(reify
@@ -870,6 +874,9 @@
870874

871875
#?(:clj
872876
(defmethod print-method ::prop [p writer]
877+
(.write writer (lvalue p)))
878+
879+
(defmethod print-dup CssProperty [p writer]
873880
(.write writer (lvalue p))))
874881

875882
#?(:clj

0 commit comments

Comments
 (0)