plumatic / dommy

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

Fix exception thrown when calling a template: Cannot create node from "" #14

Closed walterrw closed 11 years ago

walterrw commented 11 years ago

It seems that by passing an empty string to a template defined by deftemplate, the node (in this case a textnode) cannot be created and an exception is thrown, because the protocol function -elem is not defined for the type string.

The reason for this might be that the protocol is implemented for the type js/String, which does not match empty strings. A similar issue is discussed here http://dev.clojure.org/jira/browse/CLJS-347.

I added a failing test to reproduce the problem and a fix in template.cljs. I think this should fix the issue, but I'm not sure if there's other aspects that need to be considered.

mpenet commented 11 years ago

+1 as well. Imho #14 and #15 deserve some attention, both make working with dommy quite difficult on a rather large codebase that got ported from crate/hiccups, these backward compat. issues are hard to spot.

simon-nicholls commented 11 years ago

Same here. I'm converting an app from crate, and am often hitting issues 14 and 15.