Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add "px" to numeric values when they're passed into certain style pro…
…perties.
  • Loading branch information
lynaghk committed Apr 15, 2012
1 parent 2603b73 commit b55df92
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/cljs/c2/dom.cljs
Expand Up @@ -76,7 +76,13 @@
([el x] (match [x]
[(k :when keyword?)] (gstyle/getComputedStyle el (name k))
[(m :when map?)] (doseq [[k v] m] (style el k v))))
([el k v] (gstyle/setStyle el (name k) v)))
([el k v] (gstyle/setStyle el (name k)
(match [v]
[s :when string?] s
[n :when number?]
(if (#{:height :width :top :left :bottom :right} (keyword k))
(str n "px")
n)))))

(defn attr
([el] (let [attrs (.-attributes el)]
Expand Down

0 comments on commit b55df92

Please sign in to comment.