plumatic / dommy

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

omit attributes that are logically false #7

Closed mva closed 11 years ago

mva commented 11 years ago

HTML attributes that have a value are considered logically true, even if the value is the empty string. The prior code translates an element like [:option {:selected false} ...] to <option selected="false">, which the browser interprets as true.

Omitting the attribute altogether if the value is logically false (i.e. false or nil) fixes this.

Note: this pull request only touches template/add-attr!, template-compile may require a similar change.

aria42 commented 11 years ago

Happy to take the pull request, but can we move the (when v ..) around the entire case statement. I don't think anyone wants to deal with logically false values.

mva commented 11 years ago

Makes sense. In this case add-class! sets nil or adds a space, and style-str produces an empty string. They don't break, but they do not any useful work either.