plumatic / dommy

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

Adjacent nodes #19

Closed dubiousdavid closed 11 years ago

dubiousdavid commented 11 years ago

Why is the following not possible?

[[:div#first "first"]
 [:div#second "second"]]
aria42 commented 11 years ago

We're a little slammed at the moment, but we've got this fixed internally and will merge here soon.

aiba commented 11 years ago

dubiousdavid, you can do this with:

(list [:div#first "first"]
      [:div#second "second"])

Dommy (and hiccup, which it's based on) treats seqs differently from vectors. (Note that vectors are not seqs in clojure). Vectors are always treated as nodes, and seqs are always treated as a list of nodes.

I actually support the existing behavior of disambiguating node vs. list-of-nodes using vectors and seqs. This simplifies code that processes hiccup structures.

aria42, when you say this is "fixed internally", does that mean vectors are not always treated as nodes?

dubiousdavid commented 11 years ago

Thanks for shedding some light on that for me.

On Mar 21, 2013, at 6:55 PM, Aaron Iba notifications@github.com wrote:

dubiousdavid, you can do this with:

(list [:div#first "first"] [:div#second "second"]) Dommy (and hiccup, which it's based on) treats seqs differently from vectors. (Note that vectors are not seqs in clojure). Vectors are always treated as nodes, and seqs are always treated as a list of nodes.

I actually support the existing behavior of disambiguating node vs. list-of-nodes using vectors and seqs. This simplifies code that processes hiccup structures.

aria42, when you say this is "fixed internally", does that mean vectors are not always treated as nodes?

— Reply to this email directly or view it on GitHub.

aria42 commented 11 years ago

I'm sorry I misunderstood the original bug. What @aiba is saying is 100% correct. Vectors are for nodes and Lists are for document fragments. While for the runtime code you could distinguish depending on whether the first elem is a keyword, it would wreak havoc for the macro system. For those reasons, I think it's best to stick to the hiccup convention.