plumatic / dommy

A tiny ClojureScript DOM manipulation and event library
758 stars 74 forks source link

Length of children #94

Closed atroche closed 9 years ago

atroche commented 9 years ago

Hey guys,

Currently (count (children (dommy/sel1 :body))) throws [object HTMLCollection] is not ISeqable. Is there an easy way to make it so that it is ISeqable?

Cheers!

erikprice commented 9 years ago

Take a look at dommy.utils/->Array. This returns a JS array object, so there are some operations for which you may still have to use js->clj:

(-> my-children-node u/->Array sequential?) ;; => false
(-> my-children-node u/->Array js->clj sequential?) ;; => true
loganlinn commented 9 years ago

dommy aims to be a thin DOM API in this regard by always returning native objects, where applicable. I would suggest using (alength (children (dommy/sel1 :body)))