From e32c3ad044427ca76222f289f4b7c84f1702d2c8 Mon Sep 17 00:00:00 2001 From: Dan Holmsand Date: Sun, 9 Feb 2014 08:48:55 +0100 Subject: [PATCH] Fix bug in the new extract-children, and simplify wrapping --- src/reagent/impl/component.cljs | 3 ++- src/reagent/impl/template.cljs | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/reagent/impl/component.cljs b/src/reagent/impl/component.cljs index 061c522..889cdbb 100644 --- a/src/reagent/impl/component.cljs +++ b/src/reagent/impl/component.cljs @@ -35,7 +35,8 @@ (if (map? p) p))) (defn extract-children [v] - (let [first-child (if (-> v (get 1) map?) 2 1)] + (let [p (get v 1) + first-child (if (or (nil? p) (map? p)) 2 1)] (if (> (count v) first-child) (subvec v first-child)))) diff --git a/src/reagent/impl/template.cljs b/src/reagent/impl/template.cljs index e17ece3..ae4f388 100644 --- a/src/reagent/impl/template.cljs +++ b/src/reagent/impl/template.cljs @@ -123,14 +123,14 @@ (defn wrapped-render [this comp id-class] (let [inprops (aget this "props") argv (aget inprops cljs-argv) - level (aget inprops cljs-level) props (get argv 1) hasprops (or (nil? props) (map? props)) first-child (if hasprops 2 1) - jsargs (if (> (count argv) first-child) - (map-into-array as-component (inc level) - (subvec argv first-child)) - (array)) + children (if (> (count argv) first-child) + (subvec argv first-child)) + jsargs (map-into-array as-component + (inc (aget inprops cljs-level)) + children) jsprops (convert-props (if hasprops props) id-class)] (when (input-components comp) (input-render-setup this jsprops))