From 19afdd8beabda50b330b92dd7d47db8e79315ea5 Mon Sep 17 00:00:00 2001 From: rolux Date: Sun, 24 Jun 2012 15:32:35 +0200 Subject: [PATCH] fix Ox.clone(0, deep) --- source/Ox/js/Collection.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/Ox/js/Collection.js b/source/Ox/js/Collection.js index 14cc24da..ffb585c9 100644 --- a/source/Ox/js/Collection.js +++ b/source/Ox/js/Collection.js @@ -30,7 +30,9 @@ Ox.clone Returns a (shallow or deep) copy of an array or object @*/ Ox.clone = function(collection, deep) { var ret, type = Ox.typeOf(collection); - if (deep) { + if (type != 'array' && type != 'object') { + ret = collection; + } else if (deep) { ret = type == 'array' ? [] : {}; Ox.forEach(collection, function(value, key) { type = Ox.typeOf(value); @@ -38,9 +40,7 @@ Ox.clone = function(collection, deep) { ? Ox.clone(value, true) : value; }); } else { - ret = type == 'array' ? collection.slice() - : type == 'object' ? Ox.extend({}, collection) - : collection; + ret = type == 'array' ? collection.slice() : Ox.extend({}, collection) } return ret; };