From 9f07aa35f4bc44a636f164d373e1ac9f31ae6131 Mon Sep 17 00:00:00 2001 From: Dan Holmsand Date: Thu, 8 Oct 2015 18:21:56 +0200 Subject: [PATCH] Experiment with js-object element in 0.14 Doesn't seem to do much for performance, unfortunately. --- src/reagent/impl/template.cljs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/reagent/impl/template.cljs b/src/reagent/impl/template.cljs index e7a8788..6b49562 100644 --- a/src/reagent/impl/template.cljs +++ b/src/reagent/impl/template.cljs @@ -330,6 +330,33 @@ (warn (hiccup-err x "Every element in a seq should have a unique :key"))) res)) +;; From https://github.com/babel/babel/commit/1d0e68f5a19d721fe8799b1ea331041d8bf9120e +;; (def react-element-type (or (and (exists? js/Symbol) +;; (.' js/Symbol :for) +;; (.' js/Symbol for "react.element")) +;; 60103)) + +;; (defn make-element-fast [argv comp jsprops first-child] +;; (let [key (some-> jsprops (.' :key)) +;; ref (some-> jsprops (.' :ref)) +;; props (if (nil? jsprops) (js-obj) jsprops)] +;; (.! props :children +;; (case (- (count argv) first-child) +;; 0 nil +;; 1 (as-element (nth argv first-child)) +;; (reduce-kv (fn [a k v] +;; (when (>= k first-child) +;; (.push a (as-element v))) +;; a) +;; #js[] argv))) +;; (js-obj "key" key +;; "ref" ref +;; "props" props +;; "$$typeof" react-element-type +;; "type" comp +;; ;; "_store" (js-obj) +;; ))) + (defn make-element [argv comp jsprops first-child] (case (- (count argv) first-child) ;; Optimize cases of zero or one child