                ;; deep merge on ClojureScript datastructures.
                form))))]))
 
+(defn- genspec*
+  [prop-binding opts spec]
+  (let [compiled-obj
+        `(cljs.core/js-obj
+          ~@(loop [[f s :as elems] spec
+                   result []]
+              (if f
+                (cond (symbol? f)
+                      (recur (nthnext elems 2)
+                             (conj result
+                                   (name f)
+                                   (cond (= 'mixins f)
+                                         `(let [s# ~s]
+                                            (if (vector? s#)
+                                              (apply cljs.core/array s#)))
+                                         :else
+                                         s)))
+                      (list? f)
+                      (recur (next elems)
+                             (into result (wrap-fn prop-binding opts f)))
+                      :else
+                      (throw (IllegalArgumentException.
+                              (str "Invalid spec elem: " (pr-str f)))))
+                result)))]
+    `(-> default-methods
+         (js/goog.object.clone)
+         (doto (js/goog.object.extend ~compiled-obj)))))
+
 (defmacro genspec
   "Generate a spec suitable for React.createClass.
 

  (let [[docstr prop-binding spec]
        (if (string? prop-binding)
          [prop-binding (first spec) (rest spec)]
          [nil prop-binding spec])]
    (assert (vector? prop-binding))
    `(def ~name
       ~@(if docstr
           [docstr])
       (let [c# (js/React.createClass
                 (genspec ~prop-binding :this-as ~'this ~@spec))]
         (fn
           ([]
            (js/React.createElement c# (cljs.core/js-obj)))

  See https://facebook.github.io/react/docs/component-specs.html for
  available properties."
  [prop-binding & spec]
  (apply genspec* prop-binding (extract-opts spec))) 

(defmacro defreact
  "Define a variadic factory function according to spec. varargs
