 
 (declare as-velem)
 
-(defn- append-children* [ch* children]
-  (doseq [ch children]
-    (if (sequential? ch)
-      (let [head (first ch)]
-        (cond
-          (or (keyword? head) (fn? head))
-          (.push ch* (as-velem ch))
-
-          :default
-          (append-children* ch* ch)))
-      (.push ch* (as-velem ch))))
-  ch*)
-
-(defn element* [elem-factory]
+(defn- append-children* [velem-fn]
+  (fn append-ch [ch-res children]
+    (doseq [ch children]
+      (if (sequential? ch)
+        (let [head (first ch)]
+          (cond
+            (or (keyword? head) (and (ifn? head) (not (sequential? head))))
+            (.push ch-res (velem-fn ch))
+
+            :default
+            (append-ch ch-res ch)))
+        (.push ch-res (velem-fn ch))))
+    ch-res))
+
+(defn element* [elem-factory append-children-fn]
   (fn [ns-uri tag tail]
     (let [[_ tag-name id class] (re-matches re-tag tag)
           attrs? (first tail)

          (string? attr-handler)
          (do-bind-attr (get-ns-attr-setter element attr-ns attr-name) attr-value)

          (fn? attr-handler)
          (attr-handler element attr-name attr-value)

          :default

                              (if cls (str class " " cls) class)))))

          children (if have-attrs (rest tail) tail)
          children* (append-children-fn #js [] children)]
      (elem-factory ns-uri tag-name attrs children*))))

(defn- dom-node? [x]
  (and x (> (.-nodeType x) 0)))
